From clattner at apple.com Mon Jun 15 00:04:01 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 14 Jun 2009 22:04:01 -0700 Subject: [llvm-commits] [llvm] r73369 - /llvm/trunk/docs/DeveloperPolicy.html In-Reply-To: References: <200906150418.n5F4IsAh025822@zion.cs.uiuc.edu> <452A8EE2-F4B3-4CEC-8E4E-1501C3FD913E@apple.com> Message-ID: <85FDE2F9-0C28-4E04-B709-07358912162D@apple.com> On Jun 14, 2009, at 9:47 PM, Eli Friedman wrote: > On Sun, Jun 14, 2009 at 9:40 PM, Chris Lattner > wrote: >> >> On Jun 14, 2009, at 9:22 PM, Eli Friedman wrote: >> >>> On Sun, Jun 14, 2009 at 9:18 PM, Chris Lattner >>> wrote: >>>> Author: lattner >>>> Date: Sun Jun 14 23:18:54 2009 >>>> New Revision: 73369 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=73369&view=rev >>>> Log: >>>> remove some old CVS-specific arguments that don't work with SVN. >>> >>> Actually, it works, but it doesn't do anything :) >> >> $ svn diff -u >> Subcommand 'diff' doesn't accept option '-u [--show-updates]' >> Type 'svn help diff' for usage. > > Right, but "svn diff -x -u" does work, at least with recent versions > of SVN. Ah, ok! -Chris From sabre at nondot.org Mon Jun 15 00:38:04 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 15 Jun 2009 05:38:04 -0000 Subject: [llvm-commits] [llvm] r73379 - /llvm/trunk/lib/System/Win32/Path.inc Message-ID: <200906150538.n5F5c4V2028817@zion.cs.uiuc.edu> Author: lattner Date: Mon Jun 15 00:38:04 2009 New Revision: 73379 URL: http://llvm.org/viewvc/llvm-project?rev=73379&view=rev Log: "This patch implements the method with the GetModuleFileName function for windows." Patch by Benjamin Kramer! Modified: llvm/trunk/lib/System/Win32/Path.inc Modified: llvm/trunk/lib/System/Win32/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=73379&r1=73378&r2=73379&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/Path.inc (original) +++ llvm/trunk/lib/System/Win32/Path.inc Mon Jun 15 00:38:04 2009 @@ -248,7 +248,9 @@ /// GetMainExecutable - Return the path to the main executable, given the /// value of argv[0] from program startup. Path Path::GetMainExecutable(const char *argv0, void *MainAddr) { - return Path(); + char pathname[MAX_PATH]; + DWORD ret = ::GetModuleFileNameA(NULL, pathname, MAX_PATH); + return ret != MAX_PATH ? Path(pathname) : Path(); } From clattner at apple.com Mon Jun 15 00:38:40 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 14 Jun 2009 22:38:40 -0700 Subject: [llvm-commits] [PATCH] Implement sys::Path::GetMainExecutable on windows In-Reply-To: References: Message-ID: On Jun 4, 2009, at 4:19 PM, Benjamin Kramer wrote: > sys::Path::GetMainExecutable currently returns an empty path on > windows platforms. > This patch implements the method with the GetModuleFileName function. Thanks, applied! http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090615/078702.html -Chris From sabre at nondot.org Mon Jun 15 00:46:02 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 15 Jun 2009 05:46:02 -0000 Subject: [llvm-commits] [llvm] r73380 - /llvm/trunk/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll Message-ID: <200906150546.n5F5k2xB029135@zion.cs.uiuc.edu> Author: lattner Date: Mon Jun 15 00:46:02 2009 New Revision: 73380 URL: http://llvm.org/viewvc/llvm-project?rev=73380&view=rev Log: fix testcase to properly check for the patch in r73195. Modified: llvm/trunk/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll Modified: llvm/trunk/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll?rev=73380&r1=73379&r2=73380&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll Mon Jun 15 00:46:02 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep store +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {store i32 0,} ; PR4366 define void @a() { From clattner at apple.com Mon Jun 15 00:46:16 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 14 Jun 2009 22:46:16 -0700 Subject: [llvm-commits] [llvm] r73195 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2009-06-11-StoreAddrSpace.ll In-Reply-To: References: <200906111754.n5BHsvoo031066@zion.cs.uiuc.edu> Message-ID: <53067A51-18AF-4850-A3B2-D4E3B1AF6E1C@apple.com> On Jun 11, 2009, at 12:16 PM, Eli Friedman wrote: > On Thu, Jun 11, 2009 at 10:54 AM, Chris Lattner > wrote: >> --- llvm/trunk/test/Transforms/InstCombine/2009-06-11- >> StoreAddrSpace.ll (added) >> +++ llvm/trunk/test/Transforms/InstCombine/2009-06-11- >> StoreAddrSpace.ll Thu Jun 11 12:54:56 2009 >> @@ -0,0 +1,7 @@ >> +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep store >> +; PR4366 >> + >> +define void @a() { >> + store i32 0, i32 addrspace(1)* null >> + ret void >> +} > > This testcase passes even without the patch. You're right, fixed in r73380. Thanks Eli! -Chris From clattner at apple.com Mon Jun 15 00:50:21 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 14 Jun 2009 22:50:21 -0700 Subject: [llvm-commits] [llvm] r72562 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp In-Reply-To: <16e5fdf90905291341t4d2cc73vbfa5298a54019a@mail.gmail.com> References: <200905290537.n4T5bslZ002841@zion.cs.uiuc.edu> <16e5fdf90905291341t4d2cc73vbfa5298a54019a@mail.gmail.com> Message-ID: <525E2A4D-3F12-49D7-A0E1-DCB86671F697@apple.com> On May 29, 2009, at 1:41 PM, Bill Wendling wrote: > On Thu, May 28, 2009 at 10:43 PM, Chris Lattner > wrote: >> >> On May 28, 2009, at 10:37 PM, Owen Anderson wrote: >> >>> Author: resistor >>> Date: Fri May 29 00:37:54 2009 >>> New Revision: 72562 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=72562&view=rev >>> Log: >>> Fix an issue where phiMap was not being updated properly when doing >>> load PRE. >>> >>> Diagnosis and patch thanks to Jakub Staszak. >> >> Nice, does this fix the "load pre breaks llvmgcc bootstrap" problem? >> > Looks like it. :-) Great!! -Chris From clattner at apple.com Mon Jun 15 00:53:04 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 14 Jun 2009 22:53:04 -0700 Subject: [llvm-commits] [llvm] r72050 - /llvm/trunk/docs/TableGenFundamentals.html In-Reply-To: <200905182214.n4IMEkcm032623@zion.cs.uiuc.edu> References: <200905182214.n4IMEkcm032623@zion.cs.uiuc.edu> Message-ID: On May 18, 2009, at 3:14 PM, Evan Cheng wrote: > Author: evancheng > Date: Mon May 18 17:14:45 2009 > New Revision: 72050 > > URL: http://llvm.org/viewvc/llvm-project?rev=72050&view=rev > Log: > Add short descriptions of 'implicit' and 'parallel'. Hi Evan, I think this should go in code generator.html, not TGFundamentals: the TG document is independent of any particular TG backend. -Chris > > Modified: > llvm/trunk/docs/TableGenFundamentals.html > > Modified: llvm/trunk/docs/TableGenFundamentals.html > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/TableGenFundamentals.html?rev=72050&r1=72049&r2=72050&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/docs/TableGenFundamentals.html (original) > +++ llvm/trunk/docs/TableGenFundamentals.html Mon May 18 17:14:45 2009 > @@ -395,6 +395,13 @@ >
a dag value. The first element is required to be a record > definition, the > remaining elements in the list may be arbitrary other values, > including nested > `dag' values.
> +
(implicit a)
> +
an implicitly defined physical register. This tells the dag > instruction > + selection emitter the input pattern's extra definitions matches > implicit > + physical register definitions.
> +
(parallel (a), (b))
> +
a list of dags specifying parallel operations which map to > the same > + instruction.
>
!strconcat(a, b)
>
A string value that is the result of concatenating the 'a' and > 'b' > strings.
> > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Mon Jun 15 00:55:54 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 14 Jun 2009 22:55:54 -0700 Subject: [llvm-commits] [llvm] r71757 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp In-Reply-To: References: <200905140030.n4E0UJ3H020876@zion.cs.uiuc.edu> <95C426D7-58A9-4A1A-B276-40C8FEB9C03D@apple.com> Message-ID: <27A5F96D-AE57-4471-B717-DDE6FBA1BB2F@apple.com> On May 18, 2009, at 12:02 PM, Dan Gohman wrote: > > On May 13, 2009, at 6:38 PM, Chris Lattner wrote: > >> >> On May 13, 2009, at 5:30 PM, Dan Gohman wrote: >> >>> Author: djg >>> Date: Wed May 13 19:30:16 2009 >>> New Revision: 71757 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=71757&view=rev >>> Log: >>> Add an assert to turn a segfault on an unsupported inline >>> asm construct into an assertion failure. >> >> Should this use printf+exit(1)? > > > I don't know. I was just following similar code elsewhere in > the same file. Is there a conscious decision to use printf+exit > for certain cases now? We should use printf+exit in the code generator for cases where user code written in C can trigger the problem. assert should only be used for things we know cannot happen due to invariants in the code generator. Using "exit" makes it easier to find these places in the future if we ever get a real error reporting mechanism. -Chris From clattner at apple.com Mon Jun 15 01:04:59 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 14 Jun 2009 23:04:59 -0700 Subject: [llvm-commits] [PATCH] Change Compiler.h to make ARM target works under MSVC In-Reply-To: References: Message-ID: <847C9432-B2AF-4D24-A79E-AAB460C88BD3@apple.com> On May 21, 2009, at 5:30 AM, Howard Su wrote: > C++ standard (MSVC included) do support template specializations > while it doesn't support extern template specializations. So the > following define is wrong to me. > #ifdef __GNUC__ > #define EXTERN_TEMPLATE_INSTANTIATION(X) __extension__ extern > template X > #define TEMPLATE_INSTANTIATION(X) template X > #else > #define EXTERN_TEMPLATE_INSTANTIATION(X) > #define TEMPLATE_INSTANTIATION(X) <======== wrong, C++ supports > this. > #endif > Please verify. Hi Howard, Does this patch actually fix a real problem? -Chris From clattner at apple.com Mon Jun 15 01:07:24 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 14 Jun 2009 23:07:24 -0700 Subject: [llvm-commits] [llvm] r73095 - in /llvm/trunk: include/llvm/Target/TargetMachine.h include/llvm/Target/TargetOptions.h lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMRegist In-Reply-To: <305d6f60906121652v5ee48dfbn105ebd00821f1d2d@mail.gmail.com> References: <305d6f60906110010l37762b0br64c9d75b7f149915@mail.gmail.com> <41FF1606-AC7C-496F-BDFA-9A9BBFE9606B@apple.com> <305d6f60906111647i4068c9aduacdf91defae45d44@mail.gmail.com> <2C75AFA1-F51C-4FF0-ACF1-797CE8F45A03@apple.com> <305d6f60906121652v5ee48dfbn105ebd00821f1d2d@mail.gmail.com> Message-ID: <5E2002A4-14C0-4CFD-8F31-63BFA8B1CC10@apple.com> On Jun 12, 2009, at 4:52 PM, Sandeep Patel wrote: > On Fri, Jun 12, 2009 at 4:36 PM, Chris Lattner > wrote: >> >> On Jun 12, 2009, at 11:12 AM, Evan Cheng wrote: >>>> GCC did not change the target triple to indicate use of hard float; >>>> it's still arm-linux-gnueabi. GCC even allows a function >>>> attribute to >>>> change the ABI per function in support of kernel development and >>>> other >>>> cases where one may need to mix ABIs (e.g. a library that supports >>>> legacy soft float applications, etc.). >>> >>> Ok. Then it makes more sense for it to be a function note. We should >>> be able to figure out a way to change calling convention (and other >>> subtarget states). >> >> I agree: if one program can make use of multiple ABIs at the same >> time, it should not be in the triple. >> >>> I previously planned to make this a CC (64, 65, 66,...) on every >>> function, but it seemed silly to not have a default be applied to >>> handle C, fastcall, etc. >> >> What do you mean? > > I originally considered having the front-end tag every function with > the exact CC that applied to it. No function would be C or fastcall. > They'll all be tagged with a target-unique CC (CallingConv::ARM_APCS = > 64, CallingConv::ARM_AAPCS = 65, CallingConv::ARM_AAPCS_VFP = 66, > etc.). Ok, after talking to Anton about this on IRC, how about a third proposal :). 1. Each different CC gets its own number, e.g. ARM_APCS = 64, CallingConv::ARM_AAPCS = 65, CallingConv::ARM_AAPCS_VFP = 66, etc. 2. The default mapping of "ccc" depends on the target triple. This means that llvm-gcc can just produce ccc for most cases (leading to clear and simple IR) but that per-function attributes will work correctly. What do you think? -Chris From edwintorok at gmail.com Mon Jun 15 01:32:42 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Mon, 15 Jun 2009 09:32:42 +0300 Subject: [llvm-commits] [llvm] r73368 - in /llvm/trunk: include/llvm/System/Path.h lib/System/Unix/Path.inc lib/System/Win32/Path.inc In-Reply-To: <200906150417.n5F4H7RW025657@zion.cs.uiuc.edu> References: <200906150417.n5F4H7RW025657@zion.cs.uiuc.edu> Message-ID: <4A35EB0A.9060600@gmail.com> On 2009-06-15 07:17, Chris Lattner wrote: > Author: lattner > Date: Sun Jun 14 23:17:07 2009 > New Revision: 73368 > > URL: http://llvm.org/viewvc/llvm-project?rev=73368&view=rev > Log: > add a new static method to portably determine whether a patch is > absolute or not, based on a patch by Gregory Curfman! > What is an absolute patch? :) Best regards, --Edwin From deeppatel1987 at gmail.com Mon Jun 15 03:19:35 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Mon, 15 Jun 2009 01:19:35 -0700 Subject: [llvm-commits] [llvm] r73095 - in /llvm/trunk: include/llvm/Target/TargetMachine.h include/llvm/Target/TargetOptions.h lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMRegist In-Reply-To: <5E2002A4-14C0-4CFD-8F31-63BFA8B1CC10@apple.com> References: <305d6f60906110010l37762b0br64c9d75b7f149915@mail.gmail.com> <41FF1606-AC7C-496F-BDFA-9A9BBFE9606B@apple.com> <305d6f60906111647i4068c9aduacdf91defae45d44@mail.gmail.com> <2C75AFA1-F51C-4FF0-ACF1-797CE8F45A03@apple.com> <305d6f60906121652v5ee48dfbn105ebd00821f1d2d@mail.gmail.com> <5E2002A4-14C0-4CFD-8F31-63BFA8B1CC10@apple.com> Message-ID: <305d6f60906150119w222a1bc6q4642de60ec1b24af@mail.gmail.com> On Sun, Jun 14, 2009 at 11:07 PM, Chris Lattner wrote: > > On Jun 12, 2009, at 4:52 PM, Sandeep Patel wrote: > >> On Fri, Jun 12, 2009 at 4:36 PM, Chris Lattner wrote: >>> >>> On Jun 12, 2009, at 11:12 AM, Evan Cheng wrote: >>>>> >>>>> GCC did not change the target triple to indicate use of hard float; >>>>> it's still arm-linux-gnueabi. GCC even allows a function attribute to >>>>> change the ABI per function in support of kernel development and >>>>> other >>>>> cases where one may need to mix ABIs (e.g. a library that supports >>>>> legacy soft float applications, etc.). >>>> >>>> Ok. Then it makes more sense for it to be a function note. We should >>>> be able to figure out a way to change calling convention (and other >>>> subtarget states). >>> >>> I agree: if one program can make use of multiple ABIs at the same >>> time, it should not be in the triple. >>> >>>> I previously planned to make this a CC (64, 65, 66,...) on every >>>> function, but it seemed silly to not have a default be applied to >>>> handle C, fastcall, etc. >>> >>> What do you mean? >> >> I originally considered having the front-end tag every function with >> the exact CC that applied to it. No function would be C or fastcall. >> They'll all be tagged with a target-unique CC (CallingConv::ARM_APCS = >> 64, CallingConv::ARM_AAPCS = 65, CallingConv::ARM_AAPCS_VFP = 66, >> etc.). > > Ok, after talking to Anton about this on IRC, how about a third proposal :). > > 1. Each different CC gets its own number, e.g. ARM_APCS = 64, > CallingConv::ARM_AAPCS = 65, CallingConv::ARM_AAPCS_VFP = 66, etc. > 2. The default mapping of "ccc" depends on the target triple. > > This means that llvm-gcc can just produce ccc for most cases (leading to > clear and simple IR) but that per-function attributes will work correctly. > ?What do you think? I chatted with Anton on IRC about an hour later. :-) It sounds like we're talking about a patch I was planning to prepare anyway, but Anton will get to it first. deep From evan.cheng at apple.com Mon Jun 15 03:28:31 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 15 Jun 2009 08:28:31 -0000 Subject: [llvm-commits] [llvm] r73381 - in /llvm/trunk: include/llvm/CodeGen/MachineRegisterInfo.h include/llvm/Target/TargetRegisterInfo.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/MachineRegisterInfo.cpp lib/CodeGen/RegAllocLinearScan.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp lib/CodeGen/VirtRegMap.cpp lib/Target/ARM/ARMCodeEmitter.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMLoadStoreOptimizer.cpp lib/Target/ARM/ARMRegisterInfo.cpp lib/Target/ARM/ARMRegisterInfo.h test/CodeGen/ARM/ldrd.ll Message-ID: <200906150828.n5F8SVe6012833@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jun 15 03:28:29 2009 New Revision: 73381 URL: http://llvm.org/viewvc/llvm-project?rev=73381&view=rev Log: Part 1. - Change register allocation hint to a pair of unsigned integers. The hint type is zero (which means prefer the register specified as second part of the pair) or entirely target dependent. - Allow targets to specify alternative register allocation orders based on allocation hint. Part 2. - Use the register allocation hint system to implement more aggressive load / store multiple formation. - Aggressively form LDRD / STRD. These are formed *before* register allocation. It has to be done this way to shorten live interval of base and offset registers. e.g. v1025 = LDR v1024, 0 v1026 = LDR v1024, 0 => v1025,v1026 = LDRD v1024, 0 If this transformation isn't done before allocation, v1024 will overlap v1025 which means it more difficult to allocate a register pair. - Even with the register allocation hint, it may not be possible to get the desired allocation. In that case, the post-allocation load / store multiple pass must fix the ldrd / strd instructions. They can either become ldm / stm instructions or back to a pair of ldr / str instructions. This is work in progress, not yet enabled. Added: llvm/trunk/test/CodeGen/ARM/ldrd.ll Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h llvm/trunk/include/llvm/Target/TargetRegisterInfo.h llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/lib/CodeGen/VirtRegMap.cpp llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Mon Jun 15 03:28:29 2009 @@ -25,16 +25,6 @@ /// registers, including vreg register classes, use/def chains for registers, /// etc. class MachineRegisterInfo { -public: - /// Register allocation hints. - enum RegAllocHintType { - RA_None, /// No preference - RA_Preference, /// Prefer a particular register - RA_PairEven, /// Even register of a register pair - RA_PairOdd /// Odd register of a register pair - }; - -private: /// VRegInfo - Information we keep for each virtual register. The entries in /// this vector are actually converted to vreg numbers by adding the /// TargetRegisterInfo::FirstVirtualRegister delta to their index. @@ -49,12 +39,13 @@ std::vector > RegClass2VRegMap; /// RegAllocHints - This vector records register allocation hints for virtual - /// registers. For each virtual register, it keeps a register and type enum - /// pair making up the allocation hint. For example, if the hint type is - /// RA_Specified, it means the virtual register prefers the specified physical - /// register of the hint or the physical register allocated to the virtual + /// registers. For each virtual register, it keeps a register and hint type + /// pair making up the allocation hint. Hint type is target specific except + /// for the value 0 which means the second value of the pair is the preferred + /// register for allocation. For example, if the hint is <0, 1024>, it means + /// the allocator should prefer the physical register allocated to the virtual /// register of the hint. - std::vector > RegAllocHints; + std::vector > RegAllocHints; /// PhysRegUseDefLists - This is an array of the head of the use/def list for /// physical registers. @@ -191,8 +182,7 @@ /// setRegAllocationHint - Specify a register allocation hint for the /// specified virtual register. - void setRegAllocationHint(unsigned Reg, - RegAllocHintType Type, unsigned PrefReg) { + void setRegAllocationHint(unsigned Reg, unsigned Type, unsigned PrefReg) { Reg -= TargetRegisterInfo::FirstVirtualRegister; assert(Reg < VRegInfo.size() && "Invalid vreg!"); RegAllocHints[Reg].first = Type; @@ -201,7 +191,7 @@ /// getRegAllocationHint - Return the register allocation hint for the /// specified virtual register. - std::pair + std::pair getRegAllocationHint(unsigned Reg) const { Reg -= TargetRegisterInfo::FirstVirtualRegister; assert(Reg < VRegInfo.size() && "Invalid vreg!"); Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Mon Jun 15 03:28:29 2009 @@ -484,20 +484,6 @@ return 0; } - /// getRegisterPairEven - Return the even register of the register pair that - /// contains the specified register. - virtual unsigned getRegisterPairEven(const MachineFunction &MF, - unsigned Reg) const { - return 0; - } - - /// getRegisterPairOdd - Return the odd register of the register pair that - /// contains the specified register. - virtual unsigned getRegisterPairOdd(const MachineFunction &MF, - unsigned Reg) const { - return 0; - } - //===--------------------------------------------------------------------===// // Register Class Information // @@ -533,6 +519,25 @@ return NULL; } + /// getAllocationOrder - Returns the register allocation order for a specified + /// register class in the form of a pair of TargetRegisterClass iterators. + virtual std::pair + getAllocationOrder(const TargetRegisterClass *RC, + std::pair Hint, + const MachineFunction &MF) const { + return std::make_pair(RC->allocation_order_begin(MF), + RC->allocation_order_end(MF)); + } + + /// ResolveRegAllocHint - Resolves the specified register allocation hint + /// to a physical register. Returns the physical register if it is successful. + unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg, + const MachineFunction &MF) const { + if (Type == 0 && Reg && isPhysicalRegister(Reg)) + return Reg; + return 0; + } + /// targetHandlesStackFrameRounding - Returns true if the target is /// responsible for rounding up the stack frame (probably at emitPrologue /// time). Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Mon Jun 15 03:28:29 2009 @@ -507,12 +507,11 @@ // Update regalloc hint if currently there isn't one. if (TargetRegisterInfo::isVirtualRegister(reg) && TargetRegisterInfo::isVirtualRegister(Other.reg)) { - std::pair Hint = - MRI->getRegAllocationHint(reg); - if (Hint.first == MachineRegisterInfo::RA_None) { - std::pair OtherHint = + std::pair Hint = MRI->getRegAllocationHint(reg); + if (Hint.first == 0 && Hint.second == 0) { + std::pair OtherHint = MRI->getRegAllocationHint(Other.reg); - if (OtherHint.first != MachineRegisterInfo::RA_None) + if (OtherHint.first || OtherHint.second) MRI->setRegAllocationHint(reg, OtherHint.first, OtherHint.second); } } @@ -772,8 +771,7 @@ BumpPtrAllocator &VNInfoAllocator) { ranges.clear(); valnos.clear(); - std::pair Hint = - MRI->getRegAllocationHint(RHS.reg); + std::pair Hint = MRI->getRegAllocationHint(RHS.reg); MRI->setRegAllocationHint(reg, Hint.first, Hint.second); weight = RHS.weight; Modified: llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp Mon Jun 15 03:28:29 2009 @@ -65,7 +65,7 @@ // Add a reg, but keep track of whether the vector reallocated or not. void *ArrayBase = VRegInfo.empty() ? 0 : &VRegInfo[0]; VRegInfo.push_back(std::make_pair(RegClass, (MachineOperand*)0)); - RegAllocHints.push_back(std::make_pair(RA_None, 0)); + RegAllocHints.push_back(std::make_pair(0, 0)); if (!((&VRegInfo[0] == ArrayBase || VRegInfo.size() == 1))) // The vector reallocated, handle this now. Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Mon Jun 15 03:28:29 2009 @@ -281,7 +281,8 @@ /// getFreePhysReg - return a free physical register for this virtual /// register interval if we have one, otherwise return 0. unsigned getFreePhysReg(LiveInterval* cur); - unsigned getFreePhysReg(const TargetRegisterClass *RC, + unsigned getFreePhysReg(LiveInterval* cur, + const TargetRegisterClass *RC, unsigned MaxInactiveCount, SmallVector &inactiveCounts, bool SkipDGRegs); @@ -936,8 +937,7 @@ if (DstSubReg) Reg = tri_->getMatchingSuperReg(Reg, DstSubReg, RC); if (Reg && allocatableRegs_[Reg] && RC->contains(Reg)) - mri_->setRegAllocationHint(cur->reg, - MachineRegisterInfo::RA_Preference, Reg); + mri_->setRegAllocationHint(cur->reg, 0, Reg); } } } @@ -1046,8 +1046,7 @@ if (LiveInterval *NextReloadLI = hasNextReloadInterval(cur)) { // "Downgrade" physReg to try to keep physReg from being allocated until // the next reload from the same SS is allocated. - mri_->setRegAllocationHint(NextReloadLI->reg, - MachineRegisterInfo::RA_Preference, physReg); + mri_->setRegAllocationHint(NextReloadLI->reg, 0, physReg); DowngradeRegister(cur, physReg); } return; @@ -1293,7 +1292,7 @@ // It interval has a preference, it must be defined by a copy. Clear the // preference now since the source interval allocation may have been // undone as well. - mri_->setRegAllocationHint(i->reg, MachineRegisterInfo::RA_None, 0); + mri_->setRegAllocationHint(i->reg, 0, 0); else { UpgradeRegister(ii->second); } @@ -1349,15 +1348,17 @@ } } -unsigned RALinScan::getFreePhysReg(const TargetRegisterClass *RC, +unsigned RALinScan::getFreePhysReg(LiveInterval* cur, + const TargetRegisterClass *RC, unsigned MaxInactiveCount, SmallVector &inactiveCounts, bool SkipDGRegs) { unsigned FreeReg = 0; unsigned FreeRegInactiveCount = 0; - TargetRegisterClass::iterator I = RC->allocation_order_begin(*mf_); - TargetRegisterClass::iterator E = RC->allocation_order_end(*mf_); + TargetRegisterClass::iterator I, E; + tie(I, E) = tri_->getAllocationOrder(RC, + mri_->getRegAllocationHint(cur->reg), *mf_); assert(I != E && "No allocatable register in this register class!"); // Scan for the first available register. @@ -1380,7 +1381,7 @@ // return this register. if (FreeReg == 0 || FreeRegInactiveCount == MaxInactiveCount) return FreeReg; - + // Continue scanning the registers, looking for the one with the highest // inactive count. Alkis found that this reduced register pressure very // slightly on X86 (in rev 1.94 of this file), though this should probably be @@ -1440,12 +1441,12 @@ } if (!DowngradedRegs.empty()) { - unsigned FreeReg = getFreePhysReg(RC, MaxInactiveCount, inactiveCounts, + unsigned FreeReg = getFreePhysReg(cur, RC, MaxInactiveCount, inactiveCounts, true); if (FreeReg) return FreeReg; } - return getFreePhysReg(RC, MaxInactiveCount, inactiveCounts, false); + return getFreePhysReg(cur, RC, MaxInactiveCount, inactiveCounts, false); } FunctionPass* llvm::createLinearScanRegisterAllocator() { Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Mon Jun 15 03:28:29 2009 @@ -1272,26 +1272,8 @@ const TargetRegisterInfo *TRI) { if (TargetRegisterInfo::isPhysicalRegister(Reg)) return 0; - - std::pair Hint = - MRI->getRegAllocationHint(Reg); - switch (Hint.first) { - default: assert(0); - case MachineRegisterInfo::RA_None: - return 0; - case MachineRegisterInfo::RA_Preference: - return Hint.second; - case MachineRegisterInfo::RA_PairEven: - if (TargetRegisterInfo::isPhysicalRegister(Hint.second)) - return TRI->getRegisterPairOdd(MF, Hint.second); - return Hint.second; - case MachineRegisterInfo::RA_PairOdd: - if (TargetRegisterInfo::isPhysicalRegister(Hint.second)) - return TRI->getRegisterPairEven(MF, Hint.second); - return Hint.second; - } - // Shouldn't reach here. - return 0; + std::pair Hint = MRI->getRegAllocationHint(Reg); + return TRI->ResolveRegAllocHint(Hint.first, Hint.second, MF); } /// JoinCopy - Attempt to join intervals corresponding to SrcReg/DstReg, @@ -1595,8 +1577,7 @@ if (PhysJoinTweak) { if (SrcIsPhys) { if (!isWinToJoinVRWithSrcPhysReg(CopyMI, CopyMBB, DstInt, SrcInt)) { - mri_->setRegAllocationHint(DstInt.reg, - MachineRegisterInfo::RA_Preference, SrcReg); + mri_->setRegAllocationHint(DstInt.reg, 0, SrcReg); ++numAborts; DOUT << "\tMay tie down a physical register, abort!\n"; Again = true; // May be possible to coalesce later. @@ -1604,8 +1585,7 @@ } } else { if (!isWinToJoinVRWithDstPhysReg(CopyMI, CopyMBB, DstInt, SrcInt)) { - mri_->setRegAllocationHint(SrcInt.reg, - MachineRegisterInfo::RA_Preference, DstReg); + mri_->setRegAllocationHint(SrcInt.reg, 0, DstReg); ++numAborts; DOUT << "\tMay tie down a physical register, abort!\n"; Again = true; // May be possible to coalesce later. @@ -1629,8 +1609,7 @@ if (Length > Threshold && (((float)std::distance(mri_->use_begin(JoinVReg), mri_->use_end()) / Length) < Ratio)) { - mri_->setRegAllocationHint(JoinVInt.reg, - MachineRegisterInfo::RA_Preference, JoinPReg); + mri_->setRegAllocationHint(JoinVInt.reg, 0, JoinPReg); ++numAborts; DOUT << "\tMay tie down a physical register, abort!\n"; Again = true; // May be possible to coalesce later. @@ -1815,8 +1794,7 @@ TargetRegisterInfo::isVirtualRegister(ResDstInt->reg)) { const TargetRegisterClass *RC = mri_->getRegClass(ResDstInt->reg); if (!RC->contains(Preference)) - mri_->setRegAllocationHint(ResDstInt->reg, - MachineRegisterInfo::RA_None, 0); + mri_->setRegAllocationHint(ResDstInt->reg, 0, 0); } DOUT << "\n\t\tJoined. Result = "; ResDstInt->print(DOUT, tri_); @@ -2067,12 +2045,9 @@ // Update regalloc hint if both are virtual registers. if (TargetRegisterInfo::isVirtualRegister(LHS.reg) && TargetRegisterInfo::isVirtualRegister(RHS.reg)) { - std::pair RHSPref = - mri_->getRegAllocationHint(RHS.reg); - std::pair LHSPref = - mri_->getRegAllocationHint(LHS.reg); - if (RHSPref.first != MachineRegisterInfo::RA_None && - LHSPref.first == MachineRegisterInfo::RA_None) + std::pair RHSPref = mri_->getRegAllocationHint(RHS.reg); + std::pair LHSPref = mri_->getRegAllocationHint(LHS.reg); + if (RHSPref != LHSPref) mri_->setRegAllocationHint(LHS.reg, RHSPref.first, RHSPref.second); } @@ -2846,8 +2821,8 @@ } // Slightly prefer live interval that has been assigned a preferred reg. - if (mri_->getRegAllocationHint(LI.reg).first != - MachineRegisterInfo::RA_None) + std::pair Hint = mri_->getRegAllocationHint(LI.reg); + if (Hint.first || Hint.second) LI.weight *= 1.01F; // Divide the weight of the interval by its size. This encourages Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Mon Jun 15 03:28:29 2009 @@ -100,36 +100,15 @@ } unsigned VirtRegMap::getRegAllocPref(unsigned virtReg) { - std::pair Hint = - MRI->getRegAllocationHint(virtReg); - switch (Hint.first) { - default: assert(0); - case MachineRegisterInfo::RA_None: - return 0; - case MachineRegisterInfo::RA_Preference: - if (TargetRegisterInfo::isPhysicalRegister(Hint.second)) - return Hint.second; - if (hasPhys(Hint.second)) - return getPhys(Hint.second); - case MachineRegisterInfo::RA_PairEven: { - unsigned physReg = Hint.second; - if (TargetRegisterInfo::isPhysicalRegister(physReg)) - return TRI->getRegisterPairEven(*MF, physReg); - else if (hasPhys(physReg)) - return TRI->getRegisterPairEven(*MF, getPhys(physReg)); - return 0; - } - case MachineRegisterInfo::RA_PairOdd: { - unsigned physReg = Hint.second; - if (TargetRegisterInfo::isPhysicalRegister(physReg)) - return TRI->getRegisterPairOdd(*MF, physReg); - else if (hasPhys(physReg)) - return TRI->getRegisterPairOdd(*MF, getPhys(physReg)); - return 0; - } - } - // Shouldn't reach here. - return 0; + std::pair Hint = MRI->getRegAllocationHint(virtReg); + unsigned physReg = Hint.second; + if (physReg && + TargetRegisterInfo::isVirtualRegister(physReg) && hasPhys(physReg)) + physReg = getPhys(physReg); + if (Hint.first == 0) + return (physReg && TargetRegisterInfo::isPhysicalRegister(physReg)) + ? physReg : 0; + return TRI->ResolveRegAllocHint(Hint.first, physReg, *MF); } int VirtRegMap::assignVirt2StackSlot(unsigned virtReg) { Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Mon Jun 15 03:28:29 2009 @@ -900,6 +900,10 @@ // Set first operand Binary |= getMachineOpValue(MI, OpIdx++) << ARMII::RegRdShift; + // Skip LDRD and STRD's second operand. + if (TID.Opcode == ARM::LDRD || TID.Opcode == ARM::STRD) + ++OpIdx; + // Set second operand if (ImplicitRn) // Special handling for implicit use (e.g. PC). Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Mon Jun 15 03:28:29 2009 @@ -647,9 +647,8 @@ let mayLoad = 1 in { // Load doubleword -def LDRD : AI3ldd<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm, - "ldr", "d $dst, $addr", - []>, Requires<[IsARM, HasV5T]>; +def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm, + "ldr", "d $dst1, $addr", []>, Requires<[IsARM, HasV5T]>; // Indexed loads def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb), @@ -709,9 +708,8 @@ // Store doubleword let mayStore = 1 in -def STRD : AI3std<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm, - "str", "d $src, $addr", - []>, Requires<[IsARM, HasV5T]>; +def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr),StMiscFrm, + "str", "d $src1, $addr", []>, Requires<[IsARM, HasV5T]>; // Indexed stores def STR_PRE : AI2stwpr<(outs GPR:$base_wb), Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Mon Jun 15 03:28:29 2009 @@ -17,15 +17,17 @@ #include "ARMAddressingModes.h" #include "ARMMachineFunctionInfo.h" #include "ARMRegisterInfo.h" +#include "llvm/DerivedTypes.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/RegisterScavenging.h" -#include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Support/Compiler.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" @@ -82,6 +84,8 @@ SmallVector &Merges); void AdvanceRS(MachineBasicBlock &MBB, MemOpQueue &MemOps); + bool FixInvalidRegPairOp(MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MBBI); bool LoadStoreMultipleOpti(MachineBasicBlock &MBB); bool MergeReturnIntoLDM(MachineBasicBlock &MBB); }; @@ -586,13 +590,19 @@ static int getMemoryOpOffset(const MachineInstr *MI) { int Opcode = MI->getOpcode(); bool isAM2 = Opcode == ARM::LDR || Opcode == ARM::STR; + bool isAM3 = Opcode == ARM::LDRD || Opcode == ARM::STRD; unsigned NumOperands = MI->getDesc().getNumOperands(); unsigned OffField = MI->getOperand(NumOperands-3).getImm(); int Offset = isAM2 - ? ARM_AM::getAM2Offset(OffField) : ARM_AM::getAM5Offset(OffField) * 4; + ? ARM_AM::getAM2Offset(OffField) + : (isAM3 ? ARM_AM::getAM3Offset(OffField) + : ARM_AM::getAM5Offset(OffField) * 4); if (isAM2) { if (ARM_AM::getAM2Op(OffField) == ARM_AM::sub) Offset = -Offset; + } else if (isAM3) { + if (ARM_AM::getAM3Op(OffField) == ARM_AM::sub) + Offset = -Offset; } else { if (ARM_AM::getAM5Op(OffField) == ARM_AM::sub) Offset = -Offset; @@ -600,6 +610,100 @@ return Offset; } +static void InsertLDR_STR(MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MBBI, + int OffImm, bool isDef, + DebugLoc dl, unsigned NewOpc, + unsigned Reg, bool RegKill, + unsigned BaseReg, bool BaseKill, + unsigned OffReg, bool OffKill, + ARMCC::CondCodes Pred, unsigned PredReg, + const TargetInstrInfo *TII) { + unsigned Offset; + if (OffImm < 0) + Offset = ARM_AM::getAM2Opc(ARM_AM::sub, -OffImm, ARM_AM::no_shift); + else + Offset = ARM_AM::getAM2Opc(ARM_AM::add, OffImm, ARM_AM::no_shift); + if (isDef) + BuildMI(MBB, MBBI, MBBI->getDebugLoc(), TII->get(NewOpc), Reg) + .addReg(BaseReg, getKillRegState(BaseKill)) + .addReg(OffReg, getKillRegState(OffKill)) + .addImm(Offset) + .addImm(Pred).addReg(PredReg); + else + BuildMI(MBB, MBBI, MBBI->getDebugLoc(), TII->get(NewOpc)) + .addReg(Reg, getKillRegState(RegKill)) + .addReg(BaseReg, getKillRegState(BaseKill)) + .addReg(OffReg, getKillRegState(OffKill)) + .addImm(Offset) + .addImm(Pred).addReg(PredReg); +} + +bool ARMLoadStoreOpt::FixInvalidRegPairOp(MachineBasicBlock &MBB, + MachineBasicBlock::iterator &MBBI) { + MachineInstr *MI = &*MBBI; + unsigned Opcode = MI->getOpcode(); + if (Opcode == ARM::LDRD || Opcode == ARM::STRD) { + unsigned EvenReg = MI->getOperand(0).getReg(); + unsigned OddReg = MI->getOperand(1).getReg(); + unsigned EvenRegNum = TRI->getDwarfRegNum(EvenReg, false); + unsigned OddRegNum = TRI->getDwarfRegNum(OddReg, false); + if ((EvenRegNum & 1) == 0 && (EvenRegNum + 1) == OddRegNum) + return false; + + bool isDef = Opcode == ARM::LDRD; + bool EvenKill = isDef ? false : MI->getOperand(0).isKill(); + bool OddKill = isDef ? false : MI->getOperand(1).isKill(); + const MachineOperand &BaseOp = MI->getOperand(2); + unsigned BaseReg = BaseOp.getReg(); + bool BaseKill = BaseOp.isKill(); + const MachineOperand &OffOp = MI->getOperand(3); + unsigned OffReg = OffOp.getReg(); + bool OffKill = OffOp.isKill(); + int OffImm = getMemoryOpOffset(MI); + unsigned PredReg = 0; + ARMCC::CondCodes Pred = getInstrPredicate(MI, PredReg); + + if (OddRegNum > EvenRegNum && OffReg == 0 && OffImm == 0) { + // Ascending register numbers and no offset. It's safe to change it to a + // ldm or stm. + unsigned NewOpc = (Opcode == ARM::LDRD) ? ARM::LDM : ARM::STM; + BuildMI(MBB, MBBI, MBBI->getDebugLoc(), TII->get(NewOpc)) + .addReg(BaseReg, getKillRegState(BaseKill)) + .addImm(ARM_AM::getAM4ModeImm(ARM_AM::ia)) + .addImm(Pred).addReg(PredReg) + .addReg(EvenReg, getDefRegState(isDef)) + .addReg(OddReg, getDefRegState(isDef)); + } else { + // Split into two instructions. + unsigned NewOpc = (Opcode == ARM::LDRD) ? ARM::LDR : ARM::STR; + DebugLoc dl = MBBI->getDebugLoc(); + // If this is a load and base register is killed, it may have been + // re-defed by the load, make sure the first load does not clobber it. + if (isDef && + (BaseKill || OffKill) && + (TRI->regsOverlap(EvenReg, BaseReg) || + (OffReg && TRI->regsOverlap(EvenReg, OffReg)))) { + assert(!TRI->regsOverlap(OddReg, BaseReg) && + (!OffReg || !TRI->regsOverlap(OddReg, OffReg))); + InsertLDR_STR(MBB, MBBI, OffImm+4, isDef, dl, NewOpc, OddReg, OddKill, + BaseReg, false, OffReg, false, Pred, PredReg, TII); + InsertLDR_STR(MBB, MBBI, OffImm, isDef, dl, NewOpc, EvenReg, EvenKill, + BaseReg, BaseKill, OffReg, OffKill, Pred, PredReg, TII); + } else { + InsertLDR_STR(MBB, MBBI, OffImm, isDef, dl, NewOpc, EvenReg, EvenKill, + BaseReg, false, OffReg, false, Pred, PredReg, TII); + InsertLDR_STR(MBB, MBBI, OffImm+4, isDef, dl, NewOpc, OddReg, OddKill, + BaseReg, BaseKill, OffReg, OffKill, Pred, PredReg, TII); + } + } + + MBBI = prior(MBBI); + MBB.erase(MI); + } + return false; +} + /// LoadStoreMultipleOpti - An optimization pass to turn multiple LDR / STR /// ops of the same base and incrementing offset into LDM / STM ops. bool ARMLoadStoreOpt::LoadStoreMultipleOpti(MachineBasicBlock &MBB) { @@ -617,6 +721,9 @@ RS->enterBasicBlock(&MBB); MachineBasicBlock::iterator MBBI = MBB.begin(), E = MBB.end(); while (MBBI != E) { + if (FixInvalidRegPairOp(MBB, MBBI)) + continue; + bool Advance = false; bool TryMerge = false; bool Clobber = false; @@ -817,8 +924,10 @@ static char ID; ARMPreAllocLoadStoreOpt() : MachineFunctionPass(&ID) {} + const TargetData *TD; const TargetInstrInfo *TII; const TargetRegisterInfo *TRI; + const ARMSubtarget *STI; MachineRegisterInfo *MRI; virtual bool runOnMachineFunction(MachineFunction &Fn); @@ -828,6 +937,7 @@ } private: + bool SatisfyLdStDWordlignment(MachineInstr *MI); bool RescheduleOps(MachineBasicBlock *MBB, SmallVector &Ops, unsigned Base, bool isLd, @@ -838,8 +948,10 @@ } bool ARMPreAllocLoadStoreOpt::runOnMachineFunction(MachineFunction &Fn) { + TD = Fn.getTarget().getTargetData(); TII = Fn.getTarget().getInstrInfo(); TRI = Fn.getTarget().getRegisterInfo(); + STI = &Fn.getTarget().getSubtarget(); MRI = &Fn.getRegInfo(); bool Modified = false; @@ -883,6 +995,18 @@ return true; } +bool ARMPreAllocLoadStoreOpt::SatisfyLdStDWordlignment(MachineInstr *MI) { + if (!MI->hasOneMemOperand() || + !MI->memoperands_begin()->getValue() || + MI->memoperands_begin()->isVolatile()) + return false; + + unsigned Align = MI->memoperands_begin()->getAlignment(); + unsigned ReqAlign = STI->hasV6Ops() + ? TD->getPrefTypeAlignment(Type::Int64Ty) : 8; // Pre-v6 need 8-byte align + return Align >= ReqAlign; +} + bool ARMPreAllocLoadStoreOpt::RescheduleOps(MachineBasicBlock *MBB, SmallVector &Ops, unsigned Base, bool isLd, @@ -948,10 +1072,77 @@ MachineBasicBlock::iterator InsertPos = isLd ? FirstOp : LastOp; while (InsertPos != MBB->end() && MoveOps.count(InsertPos)) ++InsertPos; - for (unsigned i = 0; i != NumMove; ++i) { - MachineInstr *Op = Ops.back(); - Ops.pop_back(); - MBB->splice(InsertPos, MBB, Op); + + // If we are moving a pair of loads / stores, see if it makes sense + // to try to allocate a pair of registers that can form register pairs. + unsigned PairOpcode = 0; + unsigned Offset = 0; + + // Make sure the alignment requirement is met. + if (NumMove == 2 && SatisfyLdStDWordlignment(Ops.back())) { + int Opcode = Ops.back()->getOpcode(); + // FIXME: FLDS / FSTS -> FLDD / FSTD + if (Opcode == ARM::LDR) + PairOpcode = ARM::LDRD; + else if (Opcode == ARM::STR) + PairOpcode = ARM::STRD; + } + // Then make sure the immediate offset fits. + if (PairOpcode) { + int OffImm = getMemoryOpOffset(Ops.back()); + ARM_AM::AddrOpc AddSub = ARM_AM::add; + if (OffImm < 0) { + AddSub = ARM_AM::sub; + OffImm = - OffImm; + } + if (OffImm >= 256) // 8 bits + PairOpcode = 0; + else + Offset = ARM_AM::getAM3Opc(AddSub, OffImm); + } + + if (!PairOpcode) { + for (unsigned i = 0; i != NumMove; ++i) { + MachineInstr *Op = Ops.back(); + Ops.pop_back(); + MBB->splice(InsertPos, MBB, Op); + } + } else { + // Form the pair instruction instead. + unsigned EvenReg = 0, OddReg = 0; + unsigned BaseReg = 0, OffReg = 0, PredReg = 0; + ARMCC::CondCodes Pred; + DebugLoc dl; + for (unsigned i = 0; i != NumMove; ++i) { + MachineInstr *Op = Ops.back(); + Ops.pop_back(); + unsigned Reg = Op->getOperand(0).getReg(); + if (i == 0) { + EvenReg = Reg; + BaseReg = Op->getOperand(1).getReg(); + OffReg = Op->getOperand(2).getReg(); + Pred = getInstrPredicate(Op, PredReg); + dl = Op->getDebugLoc(); + } else + OddReg = Reg; + MBB->erase(Op); + } + if (isLd) + BuildMI(*MBB, InsertPos, dl, TII->get(PairOpcode)) + .addReg(EvenReg, RegState::Define) + .addReg(OddReg, RegState::Define) + .addReg(BaseReg).addReg(0).addImm(Offset) + .addImm(Pred).addReg(PredReg); + else + BuildMI(*MBB, InsertPos, dl, TII->get(PairOpcode)) + .addReg(EvenReg) + .addReg(OddReg) + .addReg(BaseReg).addReg(0).addImm(Offset) + .addImm(Pred).addReg(PredReg); + + // Add register allocation hints to form register pairs. + MRI->setRegAllocationHint(EvenReg, ARMRI::RegPairEven, OddReg); + MRI->setRegAllocationHint(OddReg, ARMRI::RegPairOdd, EvenReg); } NumLdStMoved += NumMove; Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Mon Jun 15 03:28:29 2009 @@ -194,10 +194,6 @@ .addReg(0).addImm(0).addImm(Pred).addReg(PredReg); } -const TargetRegisterClass *ARMRegisterInfo::getPointerRegClass() const { - return &ARM::GPRRegClass; -} - /// isLowRegister - Returns true if the register is low register r0-r7. /// bool ARMRegisterInfo::isLowRegister(unsigned Reg) const { @@ -304,6 +300,159 @@ return false; } +const TargetRegisterClass *ARMRegisterInfo::getPointerRegClass() const { + return &ARM::GPRRegClass; +} + +/// getAllocationOrder - Returns the register allocation order for a specified +/// register class in the form of a pair of TargetRegisterClass iterators. +std::pair +ARMRegisterInfo::getAllocationOrder(const TargetRegisterClass *RC, + std::pair Hint, + const MachineFunction &MF) const { + // Alternative register allocation orders when favoring even / odd registers + // of register pairs. + + // No FP, R9 is available. + static const unsigned GPREven1[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R6, ARM::R8, ARM::R10, + ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R7, + ARM::R9, ARM::R11 + }; + static const unsigned GPROdd1[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R7, ARM::R9, ARM::R11, + ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, + ARM::R8, ARM::R10 + }; + + // FP is R7, R9 is available. + static const unsigned GPREven2[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R8, ARM::R10, + ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R6, + ARM::R9, ARM::R11 + }; + static const unsigned GPROdd2[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R9, ARM::R11, + ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, + ARM::R8, ARM::R10 + }; + + // FP is R11, R9 is available. + static const unsigned GPREven3[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R6, ARM::R8, + ARM::R1, ARM::R3, ARM::R10,ARM::R12,ARM::LR, ARM::R5, ARM::R7, + ARM::R9 + }; + static const unsigned GPROdd3[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R6, ARM::R9, + ARM::R0, ARM::R2, ARM::R10,ARM::R12,ARM::LR, ARM::R4, ARM::R7, + ARM::R8 + }; + + // No FP, R9 is not available. + static const unsigned GPREven4[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R6, ARM::R10, + ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R7, ARM::R8, + ARM::R11 + }; + static const unsigned GPROdd4[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R7, ARM::R11, + ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, ARM::R8, + ARM::R10 + }; + + // FP is R7, R9 is not available. + static const unsigned GPREven5[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R10, + ARM::R1, ARM::R3, ARM::R12,ARM::LR, ARM::R5, ARM::R6, ARM::R8, + ARM::R11 + }; + static const unsigned GPROdd5[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R11, + ARM::R0, ARM::R2, ARM::R12,ARM::LR, ARM::R4, ARM::R6, ARM::R8, + ARM::R10 + }; + + // FP is R11, R9 is not available. + static const unsigned GPREven6[] = { + ARM::R0, ARM::R2, ARM::R4, ARM::R6, + ARM::R1, ARM::R3, ARM::R10,ARM::R12,ARM::LR, ARM::R5, ARM::R7, ARM::R8 + }; + static const unsigned GPROdd6[] = { + ARM::R1, ARM::R3, ARM::R5, ARM::R7, + ARM::R0, ARM::R2, ARM::R10,ARM::R12,ARM::LR, ARM::R4, ARM::R6, ARM::R8 + }; + + + if (Hint.first == ARMRI::RegPairEven) { + if (!hasFP(MF)) { + if (!STI.isR9Reserved()) + return std::make_pair(GPREven1, + GPREven1 + (sizeof(GPREven1)/sizeof(unsigned))); + else + return std::make_pair(GPREven4, + GPREven4 + (sizeof(GPREven4)/sizeof(unsigned))); + } else if (FramePtr == ARM::R7) { + if (!STI.isR9Reserved()) + return std::make_pair(GPREven2, + GPREven2 + (sizeof(GPREven2)/sizeof(unsigned))); + else + return std::make_pair(GPREven5, + GPREven5 + (sizeof(GPREven5)/sizeof(unsigned))); + } else { // FramePtr == ARM::R11 + if (!STI.isR9Reserved()) + return std::make_pair(GPREven3, + GPREven3 + (sizeof(GPREven3)/sizeof(unsigned))); + else + return std::make_pair(GPREven6, + GPREven6 + (sizeof(GPREven6)/sizeof(unsigned))); + } + } else if (Hint.first == ARMRI::RegPairOdd) { + if (!hasFP(MF)) { + if (!STI.isR9Reserved()) + return std::make_pair(GPROdd1, + GPROdd1 + (sizeof(GPROdd1)/sizeof(unsigned))); + else + return std::make_pair(GPROdd4, + GPROdd4 + (sizeof(GPROdd4)/sizeof(unsigned))); + } else if (FramePtr == ARM::R7) { + if (!STI.isR9Reserved()) + return std::make_pair(GPROdd2, + GPROdd2 + (sizeof(GPROdd2)/sizeof(unsigned))); + else + return std::make_pair(GPROdd5, + GPROdd5 + (sizeof(GPROdd5)/sizeof(unsigned))); + } else { // FramePtr == ARM::R11 + if (!STI.isR9Reserved()) + return std::make_pair(GPROdd3, + GPROdd3 + (sizeof(GPROdd3)/sizeof(unsigned))); + else + return std::make_pair(GPROdd6, + GPROdd6 + (sizeof(GPROdd6)/sizeof(unsigned))); + } + } + return std::make_pair(RC->allocation_order_begin(MF), + RC->allocation_order_end(MF)); +} + +/// ResolveRegAllocHint - Resolves the specified register allocation hint +/// to a physical register. Returns the physical register if it is successful. +unsigned +ARMRegisterInfo::ResolveRegAllocHint(unsigned Type, unsigned Reg, + const MachineFunction &MF) const { + if (Reg == 0 || !isPhysicalRegister(Reg)) + return 0; + if (Type == 0) + return Reg; + else if (Type == (unsigned)ARMRI::RegPairOdd) + // Odd register. + return getRegisterPairOdd(Reg, MF); + else if (Type == (unsigned)ARMRI::RegPairEven) + // Even register. + return getRegisterPairEven(Reg, MF); + return 0; +} + bool ARMRegisterInfo::requiresRegisterScavenging(const MachineFunction &MF) const { const ARMFunctionInfo *AFI = MF.getInfo(); @@ -1525,4 +1674,152 @@ return ARMGenRegisterInfo::getDwarfRegNumFull(RegNum, 0); } +unsigned ARMRegisterInfo::getRegisterPairEven(unsigned Reg, + const MachineFunction &MF) const { + switch (Reg) { + default: break; + // Return 0 if either register of the pair is a special register. + // So no R12, etc. + case ARM::R0: case ARM::R1: + return ARM::R0; + case ARM::R2: case ARM::R3: + // FIXME! + return STI.isThumb() ? 0 : ARM::R2; + case ARM::R4: case ARM::R5: + return ARM::R4; + case ARM::R6: case ARM::R7: + return isReservedReg(MF, ARM::R7) ? 0 : ARM::R6; + case ARM::R8: case ARM::R9: + return isReservedReg(MF, ARM::R9) ? 0 :ARM::R8; + case ARM::R10: case ARM::R11: + return isReservedReg(MF, ARM::R11) ? 0 : ARM::R10; + + case ARM::S0: case ARM::S1: + return ARM::S0; + case ARM::S2: case ARM::S3: + return ARM::S2; + case ARM::S4: case ARM::S5: + return ARM::S4; + case ARM::S6: case ARM::S7: + return ARM::S6; + case ARM::S8: case ARM::S9: + return ARM::S8; + case ARM::S10: case ARM::S11: + return ARM::S10; + case ARM::S12: case ARM::S13: + return ARM::S12; + case ARM::S14: case ARM::S15: + return ARM::S14; + case ARM::S16: case ARM::S17: + return ARM::S16; + case ARM::S18: case ARM::S19: + return ARM::S18; + case ARM::S20: case ARM::S21: + return ARM::S20; + case ARM::S22: case ARM::S23: + return ARM::S22; + case ARM::S24: case ARM::S25: + return ARM::S24; + case ARM::S26: case ARM::S27: + return ARM::S26; + case ARM::S28: case ARM::S29: + return ARM::S28; + case ARM::S30: case ARM::S31: + return ARM::S30; + + case ARM::D0: case ARM::D1: + return ARM::D0; + case ARM::D2: case ARM::D3: + return ARM::D2; + case ARM::D4: case ARM::D5: + return ARM::D4; + case ARM::D6: case ARM::D7: + return ARM::D6; + case ARM::D8: case ARM::D9: + return ARM::D8; + case ARM::D10: case ARM::D11: + return ARM::D10; + case ARM::D12: case ARM::D13: + return ARM::D12; + case ARM::D14: case ARM::D15: + return ARM::D14; + } + + return 0; +} + +unsigned ARMRegisterInfo::getRegisterPairOdd(unsigned Reg, + const MachineFunction &MF) const { + switch (Reg) { + default: break; + // Return 0 if either register of the pair is a special register. + // So no R12, etc. + case ARM::R0: case ARM::R1: + return ARM::R1; + case ARM::R2: case ARM::R3: + // FIXME! + return STI.isThumb() ? 0 : ARM::R3; + case ARM::R4: case ARM::R5: + return ARM::R5; + case ARM::R6: case ARM::R7: + return isReservedReg(MF, ARM::R7) ? 0 : ARM::R7; + case ARM::R8: case ARM::R9: + return isReservedReg(MF, ARM::R9) ? 0 :ARM::R9; + case ARM::R10: case ARM::R11: + return isReservedReg(MF, ARM::R11) ? 0 : ARM::R11; + + case ARM::S0: case ARM::S1: + return ARM::S1; + case ARM::S2: case ARM::S3: + return ARM::S3; + case ARM::S4: case ARM::S5: + return ARM::S5; + case ARM::S6: case ARM::S7: + return ARM::S7; + case ARM::S8: case ARM::S9: + return ARM::S9; + case ARM::S10: case ARM::S11: + return ARM::S11; + case ARM::S12: case ARM::S13: + return ARM::S13; + case ARM::S14: case ARM::S15: + return ARM::S15; + case ARM::S16: case ARM::S17: + return ARM::S17; + case ARM::S18: case ARM::S19: + return ARM::S19; + case ARM::S20: case ARM::S21: + return ARM::S21; + case ARM::S22: case ARM::S23: + return ARM::S23; + case ARM::S24: case ARM::S25: + return ARM::S25; + case ARM::S26: case ARM::S27: + return ARM::S27; + case ARM::S28: case ARM::S29: + return ARM::S29; + case ARM::S30: case ARM::S31: + return ARM::S31; + + case ARM::D0: case ARM::D1: + return ARM::D1; + case ARM::D2: case ARM::D3: + return ARM::D3; + case ARM::D4: case ARM::D5: + return ARM::D5; + case ARM::D6: case ARM::D7: + return ARM::D7; + case ARM::D8: case ARM::D9: + return ARM::D9; + case ARM::D10: case ARM::D11: + return ARM::D11; + case ARM::D12: case ARM::D13: + return ARM::D13; + case ARM::D14: case ARM::D15: + return ARM::D15; + } + + return 0; +} + #include "ARMGenRegisterInfo.inc" Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h?rev=73381&r1=73380&r2=73381&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h Mon Jun 15 03:28:29 2009 @@ -22,12 +22,17 @@ class TargetInstrInfo; class Type; +/// Register allocation hints. +namespace ARMRI { + enum { + RegPairOdd = 1, + RegPairEven = 2 + }; +} + struct ARMRegisterInfo : public ARMGenRegisterInfo { const TargetInstrInfo &TII; const ARMSubtarget &STI; -private: - /// FramePtr - ARM physical register used as frame ptr. - unsigned FramePtr; public: ARMRegisterInfo(const TargetInstrInfo &tii, const ARMSubtarget &STI); @@ -49,10 +54,6 @@ /// if the register is a single precision VFP register. static unsigned getRegisterNumbering(unsigned RegEnum, bool &isSPVFP); - /// getPointerRegClass - Return the register class to use to hold pointers. - /// This is used for addressing modes. - const TargetRegisterClass *getPointerRegClass() const; - /// Code Generation virtual methods... const TargetRegisterClass * getPhysicalRegisterRegClass(unsigned Reg, MVT VT = MVT::Other) const; @@ -65,6 +66,16 @@ bool isReservedReg(const MachineFunction &MF, unsigned Reg) const; + const TargetRegisterClass *getPointerRegClass() const; + + std::pair + getAllocationOrder(const TargetRegisterClass *RC, + std::pair Hint, + const MachineFunction &MF) const; + + unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg, + const MachineFunction &MF) const; + bool requiresRegisterScavenging(const MachineFunction &MF) const; bool hasFP(const MachineFunction &MF) const; @@ -95,6 +106,15 @@ int getDwarfRegNum(unsigned RegNum, bool isEH) const; bool isLowRegister(unsigned Reg) const; + +private: + /// FramePtr - ARM physical register used as frame ptr. + unsigned FramePtr; + + unsigned getRegisterPairEven(unsigned Reg, const MachineFunction &MF) const; + + unsigned getRegisterPairOdd(unsigned Reg, const MachineFunction &MF) const; + }; } // end namespace llvm Added: llvm/trunk/test/CodeGen/ARM/ldrd.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/ldrd.ll?rev=73381&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/ldrd.ll (added) +++ llvm/trunk/test/CodeGen/ARM/ldrd.ll Mon Jun 15 03:28:29 2009 @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | llc -mtriple=armv6-apple-darwin -arm-pre-alloc-loadstore-opti | grep ldrd +; RUN: llvm-as < %s | llc -mtriple=armv5-apple-darwin -arm-pre-alloc-loadstore-opti | not grep ldrd +; RUN: llvm-as < %s | llc -mtriple=armv6-eabi -arm-pre-alloc-loadstore-opti | not grep ldrd +; rdar://r6949835 + + at b = external global i64* + +define i64 @t(i64 %a) nounwind readonly { +entry: + %0 = load i64** @b, align 4 + %1 = load i64* %0, align 4 + %2 = mul i64 %1, %a + ret i64 %2 +} From rafael.espindola at gmail.com Mon Jun 15 05:14:24 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 15 Jun 2009 10:14:24 -0000 Subject: [llvm-commits] [llvm] r73383 - /llvm/trunk/tools/gold/gold-plugin.cpp Message-ID: <200906151014.n5FAEPoc017058@zion.cs.uiuc.edu> Author: rafael Date: Mon Jun 15 05:14:18 2009 New Revision: 73383 URL: http://llvm.org/viewvc/llvm-project?rev=73383&view=rev Log: Remove the gcc= option. llvm-gcc uses only as= Look for as in the path. Doing it here instead of llvm-gcc because llvm-gcc has nothing as convenient as sys::Program::FindProgramByName. Modified: llvm/trunk/tools/gold/gold-plugin.cpp Modified: llvm/trunk/tools/gold/gold-plugin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=73383&r1=73382&r2=73383&view=diff ============================================================================== --- llvm/trunk/tools/gold/gold-plugin.cpp (original) +++ llvm/trunk/tools/gold/gold-plugin.cpp Mon Jun 15 05:14:18 2009 @@ -18,6 +18,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/System/Path.h" +#include "llvm/System/Program.h" #include #include @@ -44,7 +45,6 @@ int gold_version = 0; bool generate_api_file = false; - const char *gcc_path = NULL; const char *as_path = NULL; struct claimed_file { @@ -103,13 +103,6 @@ case LDPT_OPTION: if (strcmp("generate-api-file", tv->tv_u.tv_string) == 0) { generate_api_file = true; - } else if (strncmp("gcc=", tv->tv_u.tv_string, 4) == 0) { - if (gcc_path) { - (*message)(LDPL_WARNING, "Path to gcc specified twice. " - "Discarding %s", tv->tv_u.tv_string); - } else { - gcc_path = strdup(tv->tv_u.tv_string + 4); - } } else if (strncmp("as=", tv->tv_u.tv_string, 3) == 0) { if (as_path) { (*message)(LDPL_WARNING, "Path to as specified twice. " @@ -352,10 +345,10 @@ lto_codegen_set_pic_model(cg, output_type); lto_codegen_set_debug_model(cg, LTO_DEBUG_MODEL_DWARF); - if (gcc_path) - lto_codegen_set_gcc_path(cg, gcc_path); - if (as_path) - lto_codegen_set_assembler_path(cg, as_path); + if (as_path) { + sys::Path p = sys::Program::FindProgramByName(as_path); + lto_codegen_set_assembler_path(cg, p.c_str()); + } size_t bufsize = 0; const char *buffer = static_cast(lto_codegen_compile(cg, From rafael.espindola at gmail.com Mon Jun 15 05:16:08 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 15 Jun 2009 10:16:08 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73384 - /llvm-gcc-4.2/trunk/gcc/gcc.c Message-ID: <200906151016.n5FAG9hP017118@zion.cs.uiuc.edu> Author: rafael Date: Mon Jun 15 05:16:08 2009 New Revision: 73384 URL: http://llvm.org/viewvc/llvm-project?rev=73384&view=rev Log: If we can't find the assembler in any of the -B directories, pass "as" to the plugin. Modified: llvm-gcc-4.2/trunk/gcc/gcc.c Modified: llvm-gcc-4.2/trunk/gcc/gcc.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/gcc.c?rev=73384&r1=73383&r2=73384&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/gcc.c (original) +++ llvm-gcc-4.2/trunk/gcc/gcc.c Mon Jun 15 05:16:08 2009 @@ -7190,6 +7190,8 @@ fatal ("-use-gold-plugin, but libLLVMgold.so not found."); } gold_plugin_as_spec = find_a_file (&exec_prefixes, "as", X_OK, false); + if (!gold_plugin_as_spec) + gold_plugin_as_spec = "as"; #endif /* LLVM LOCAL end */ /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables From benny.kra at googlemail.com Mon Jun 15 06:18:03 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 15 Jun 2009 13:18:03 +0200 Subject: [llvm-commits] [PATCH] work around a nasty g++/glibc incompatiblity In-Reply-To: <4A34D70D.6050200@googlemail.com> References: <4A34D70D.6050200@googlemail.com> Message-ID: <683DC061-939C-467F-A862-809AD34313E7@gmail.com> Dan Gohman wrote: > Instead of copying the string into the buffer for the GLIBC case, > could > you add a new char* variable at the top of the function and assign to > it the > address of the buffer, and make the std::string construction at the > bottom > use that variable instead of the buffer? Then, the glibc case could > just > reassign the char* variable. -------------- next part -------------- A non-text attachment was scrubbed... Name: glibcstrerror_r.patch Type: application/octet-stream Size: 1017 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090615/7e76fc56/attachment.obj -------------- next part -------------- From edwintorok at gmail.com Mon Jun 15 07:17:51 2009 From: edwintorok at gmail.com (Torok Edwin) Date: Mon, 15 Jun 2009 12:17:51 -0000 Subject: [llvm-commits] [llvm] r73385 - /llvm/trunk/docs/CodeGenerator.html Message-ID: <200906151217.n5FCHq3N021353@zion.cs.uiuc.edu> Author: edwin Date: Mon Jun 15 07:17:44 2009 New Revision: 73385 URL: http://llvm.org/viewvc/llvm-project?rev=73385&view=rev Log: x86_64 was completely missing from the target triples supported by the X86 code generator! Modified: llvm/trunk/docs/CodeGenerator.html Modified: llvm/trunk/docs/CodeGenerator.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CodeGenerator.html?rev=73385&r1=73384&r2=73385&view=diff ============================================================================== --- llvm/trunk/docs/CodeGenerator.html (original) +++ llvm/trunk/docs/CodeGenerator.html Mon Jun 15 07:17:44 2009 @@ -1773,6 +1773,8 @@
  • i386-pc-mingw32msvc — MingW crosscompiler on Linux
  • i686-apple-darwin* — Apple Darwin on X86
  • + +
  • x86_64-unknown-linux-gnu — Linux
  • From arnold.schwaighofer at gmail.com Mon Jun 15 09:43:37 2009 From: arnold.schwaighofer at gmail.com (Arnold Schwaighofer) Date: Mon, 15 Jun 2009 14:43:37 -0000 Subject: [llvm-commits] [llvm] r73387 - in /llvm/trunk: lib/CodeGen/SelectionDAG/TargetLowering.cpp test/CodeGen/X86/2009-06-15-not-a-tail-call.ll Message-ID: <200906151443.n5FEhbUJ026309@zion.cs.uiuc.edu> Author: arnolds Date: Mon Jun 15 09:43:36 2009 New Revision: 73387 URL: http://llvm.org/viewvc/llvm-project?rev=73387&view=rev Log: CheckTailCallReturnConstraints is missing a check on the incomming chain of the RETURN node. The incomming chain must be the outgoing chain of the CALL node. This causes the backend to identify tail calls that are not tail calls. This patch fixes this. Added: llvm/trunk/test/CodeGen/X86/2009-06-15-not-a-tail-call.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=73387&r1=73386&r2=73387&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Mon Jun 15 09:43:36 2009 @@ -2584,8 +2584,12 @@ // Check that operand of the RET node sources from the CALL node. The RET node // has at least two operands. Operand 0 holds the chain. Operand 1 holds the // value. + // Also we need to check that there is no code in between the call and the + // return. Hence we also check that the incomming chain to the return sources + // from the outgoing chain of the call. if (NumOps > 1 && - IgnoreHarmlessInstructions(Ret.getOperand(1)) == SDValue(TheCall,0)) + IgnoreHarmlessInstructions(Ret.getOperand(1)) == SDValue(TheCall,0) && + Ret.getOperand(0) == SDValue(TheCall, TheCall->getNumValues()-1)) return true; // void return: The RET node has the chain result value of the CALL node as // input. Added: llvm/trunk/test/CodeGen/X86/2009-06-15-not-a-tail-call.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-06-15-not-a-tail-call.ll?rev=73387&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-06-15-not-a-tail-call.ll (added) +++ llvm/trunk/test/CodeGen/X86/2009-06-15-not-a-tail-call.ll Mon Jun 15 09:43:36 2009 @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | llc -march=x86 -tailcallopt | not grep TAILCALL + +; Bug 4396. This tail call can NOT be optimized. + +declare fastcc i8* @_D3gcx2GC12mallocNoSyncMFmkZPv() nounwind + +define fastcc i8* @_D3gcx2GC12callocNoSyncMFmkZPv() nounwind { +entry: + %tmp6 = tail call fastcc i8* @_D3gcx2GC12mallocNoSyncMFmkZPv() ; [#uses=2] + %tmp9 = tail call i8* @memset(i8* %tmp6, i32 0, i64 2) ; [#uses=0] + ret i8* %tmp6 +} + +declare i8* @memset(i8*, i32, i64) From resistor at mac.com Mon Jun 15 12:16:55 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 15 Jun 2009 10:16:55 -0700 Subject: [llvm-commits] [PATCH] LockedManagedStatic Message-ID: <0DBD89AB-971A-4367-BE69-8DE2533752CA@mac.com> Here's my next proposal for the long-term goal of making LLVM thread- safe. The concept here is to create a new subclass of ManagedStaticBase, LockedManagedStatic. These objects pair a mutex with the object that they're guarding, and hook the mutex up to be initialized automatically when llvm_start_multithreaded() is called. This does have slight overhead in that it adds a pointer to ManagedStaticBase. This could probably be avoided by adding another class to the hierarch (LockedManagedStaticBase?), but that seemed overly complex for fairly small benefit. Comments welcome! --Owen -------------- next part -------------- A non-text attachment was scrubbed... Name: threading.diff Type: application/octet-stream Size: 6331 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090615/2445932d/attachment.obj From gohman at apple.com Mon Jun 15 12:37:10 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 17:37:10 -0000 Subject: [llvm-commits] [llvm] r73394 - /llvm/trunk/docs/LangRef.html Message-ID: <200906151737.n5FHbA71032426@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 12:37:09 2009 New Revision: 73394 URL: http://llvm.org/viewvc/llvm-project?rev=73394&view=rev Log: Reword the description of the noredzone attribute. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=73394&r1=73393&r2=73394&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Jun 15 12:37:09 2009 @@ -1106,8 +1106,9 @@ an sspreq attribute.
    noredzone
    -
    This attribute indicates that the code generator should not enforce red zone -mandated by target specific ABI.
    +
    This attribute indicates that the code generator should not use a +red zone, even if it would otherwise be supported by the target-specific ABI. +
    noimplicitfloat
    This attributes disables implicit floating point instructions.
    From gohman at apple.com Mon Jun 15 13:05:46 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 18:05:46 -0000 Subject: [llvm-commits] [llvm] r73396 - /llvm/trunk/lib/System/Unix/Unix.h Message-ID: <200906151805.n5FI5kIM001212@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 13:05:46 2009 New Revision: 73396 URL: http://llvm.org/viewvc/llvm-project?rev=73396&view=rev Log: glibc has two versions of strerror_r, a standards compliant one and a GNU specific one. The GNU one is chosen when _GNU_SOURCE is defined. g++ always defines _GNU_SOURCE on linux platforms because glibc's headers won't compile in C++ mode without it. The GNU strerror_r doesn't always modify the buffer which causes empty error messages on linux. This patch changes MakeErrMsg to use the return value of strerror_r to get the string instead of assuming the buffer will be modified, on GLIBC. Patch by Benjamin Kramer! Modified: llvm/trunk/lib/System/Unix/Unix.h Modified: llvm/trunk/lib/System/Unix/Unix.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Unix.h?rev=73396&r1=73395&r2=73396&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Unix.h (original) +++ llvm/trunk/lib/System/Unix/Unix.h Mon Jun 15 13:05:46 2009 @@ -79,12 +79,19 @@ return true; char buffer[MAXPATHLEN]; buffer[0] = 0; + char* str = buffer; if (errnum == -1) errnum = errno; #ifdef HAVE_STRERROR_R // strerror_r is thread-safe. if (errnum) +# if defined(__GLIBC__) && defined(_GNU_SOURCE) + // glibc defines its own incompatible version of strerror_r + // which may not use the buffer supplied. + str = strerror_r(errnum,buffer,MAXPATHLEN-1); +# else strerror_r(errnum,buffer,MAXPATHLEN-1); +# endif #elif HAVE_STRERROR // Copy the thread un-safe result of strerror into // the buffer as fast as possible to minimize impact @@ -97,7 +104,7 @@ // but, oh well, just use a generic message sprintf(buffer, "Error #%d", errnum); #endif - *ErrMsg = prefix + ": " + buffer; + *ErrMsg = prefix + ": " + str; return true; } From gohman at apple.com Mon Jun 15 13:06:06 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 11:06:06 -0700 Subject: [llvm-commits] [PATCH] work around a nasty g++/glibc incompatiblity In-Reply-To: <683DC061-939C-467F-A862-809AD34313E7@gmail.com> References: <4A34D70D.6050200@googlemail.com> <683DC061-939C-467F-A862-809AD34313E7@gmail.com> Message-ID: <43DD762E-362C-4CD3-A784-17F3BD8348E5@apple.com> On Jun 15, 2009, at 4:18 AM, Benjamin Kramer wrote: > > Applied, thanks! Dan From gohman at apple.com Mon Jun 15 13:15:27 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 11:15:27 -0700 Subject: [llvm-commits] [PATCH] Avoid use after free in ScalarEvolution In-Reply-To: <4A16816C.7080405@gmail.com> References: <4A16816C.7080405@gmail.com> Message-ID: <4AFCEFE6-6B21-4B33-998F-DACE37C5235E@apple.com> Hi Edwin, WritingAnLLVMPass.htm's description of releaseMemory says "This method is called after the run* method for the class, before the next call of run* in your pass." This suggests that it's a bug in the PassManager for not calling releaseMemory for on-the-fly analyses. On the other hand, I do see several other existing passes calling releaseMemory or the equivalent at the top of their run functions. Dan On May 22, 2009, at 3:41 AM, T?r?k Edwin wrote: > Hi, > > When running ScalarEvolution on-the-fly (from a ModulePass), and using > getSCEVAtScope I get use-after-free errors. > This is because nobody calls releaseMemory() for ScalarEvolution > before > running it again, and LoopInfo has already been run for the new > function > , hence freeing the loopinfo of the previous function. But > ScalarEvolution still has Loop* in ValuesAtScopes (and other maps), > which cause use-after-free errors. > > The attached patch simply adds a call to releaseMemory(). > OK to commit? > > Or should the on-the-fly passmanager call releaseMemory before > rerunning > the pass? > > Best regards, > --Edwin > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From gohman at apple.com Mon Jun 15 13:22:49 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 18:22:49 -0000 Subject: [llvm-commits] [llvm] r73397 - /llvm/trunk/docs/WritingAnLLVMPass.html Message-ID: <200906151822.n5FIMncM001793@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 13:22:49 2009 New Revision: 73397 URL: http://llvm.org/viewvc/llvm-project?rev=73397&view=rev Log: Fix a typo. Modified: llvm/trunk/docs/WritingAnLLVMPass.html Modified: llvm/trunk/docs/WritingAnLLVMPass.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/WritingAnLLVMPass.html?rev=73397&r1=73396&r2=73397&view=diff ============================================================================== --- llvm/trunk/docs/WritingAnLLVMPass.html (original) +++ llvm/trunk/docs/WritingAnLLVMPass.html Mon Jun 15 13:22:49 2009 @@ -1537,7 +1537,7 @@

    If you are writing an analysis or any other pass that retains a significant amount of state (for use by another pass which "requires" your pass and uses the getAnalysis method) you should implement -releaseMEmory to, well, release the memory allocated to maintain this +releaseMemory to, well, release the memory allocated to maintain this internal state. This method is called after the run* method for the class, before the next call of run* in your pass.

    From gohman at apple.com Mon Jun 15 13:30:16 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 18:30:16 -0000 Subject: [llvm-commits] [llvm] r73398 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp Message-ID: <200906151830.n5FIUGst002010@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 13:30:15 2009 New Revision: 73398 URL: http://llvm.org/viewvc/llvm-project?rev=73398&view=rev Log: Make the EnableLoadPRE variable static. 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=73398&r1=73397&r2=73398&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Jun 15 13:30:15 2009 @@ -48,7 +48,7 @@ static cl::opt EnablePRE("enable-pre", cl::init(true), cl::Hidden); -cl::opt EnableLoadPRE("enable-load-pre", cl::init(true)); +static cl::opt EnableLoadPRE("enable-load-pre", cl::init(true)); //===----------------------------------------------------------------------===// // ValueTable Class From isanbard at gmail.com Mon Jun 15 13:36:34 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 15 Jun 2009 18:36:34 -0000 Subject: [llvm-commits] [llvm] r73399 - /llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll Message-ID: <200906151836.n5FIaYHF002200@zion.cs.uiuc.edu> Author: void Date: Mon Jun 15 13:36:34 2009 New Revision: 73399 URL: http://llvm.org/viewvc/llvm-project?rev=73399&view=rev Log: Add another testcase for r71478. Added: llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll Added: llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll?rev=73399&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll (added) +++ llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll Mon Jun 15 13:36:34 2009 @@ -0,0 +1,89 @@ +; RUN: llvm-as < %s | llc -march=x86 +; +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" +target triple = "x86_64-apple-darwin10.0" + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8*, i32 } + %llvm.dbg.composite.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, { }*, { }*, i32 } + %llvm.dbg.derivedtype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, { }* } + %llvm.dbg.subprogram.type = type { i32, { }*, { }*, i8*, i8*, i8*, { }*, i32, { }*, i1, i1 } + %struct.A = type <{ i8 }> + %struct.__class_type_info_pseudo = type { %struct.__type_info_pseudo } + %struct.__type_info_pseudo = type { i8*, i8* } + at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] + at .str = internal constant [12 x i8] c"testcase.ii\00", section "llvm.metadata" ; <[12 x i8]*> [#uses=1] + at .str1 = internal constant [22 x i8] c"/Volumes/Sandbox/swb/\00", section "llvm.metadata" ; <[22 x i8]*> [#uses=1] + at .str2 = internal constant [57 x i8] c"4.2.1 (Based on Apple Inc. build 5646) (LLVM build 2110)\00", section "llvm.metadata" ; <[57 x i8]*> [#uses=1] + at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 4, i8* getelementptr ([12 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([22 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([57 x i8]* @.str2, i32 0, i32 0), i1 true, i1 true, i8* null, i32 0 }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] + at .str3 = internal constant [2 x i8] c"A\00", section "llvm.metadata" ; <[2 x i8]*> [#uses=1] + at llvm.dbg.derivedtype = internal constant %llvm.dbg.derivedtype.type { i32 458767, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 64, i64 64, i64 0, i32 0, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite11 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] + at llvm.dbg.array = internal constant [2 x { }*] [{ }* null, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] + at llvm.dbg.composite4 = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at llvm.dbg.subprograms = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 46 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] + at .str5 = internal constant [5 x i8] c"Func\00", section "llvm.metadata" ; <[5 x i8]*> [#uses=1] + at .str6 = internal constant [13 x i8] c"_ZN1A4FuncEv\00", section "llvm.metadata" ; <[13 x i8]*> [#uses=1] + at llvm.dbg.subprogram = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([5 x i8]* @.str5, i32 0, i32 0), i8* getelementptr ([5 x i8]* @.str5, i32 0, i32 0), i8* getelementptr ([13 x i8]* @.str6, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 4, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite4 to { }*), i1 false, i1 false }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at .str7 = internal constant [4 x i8] c"Bar\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] + at .str8 = internal constant [12 x i8] c"_ZN1A3BarEv\00", section "llvm.metadata" ; <[12 x i8]*> [#uses=1] + at llvm.dbg.subprogram9 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str7, i32 0, i32 0), i8* getelementptr ([4 x i8]* @.str7, i32 0, i32 0), i8* getelementptr ([12 x i8]* @.str8, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 7, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite4 to { }*), i1 false, i1 false }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at llvm.dbg.array10 = internal constant [2 x { }*] [{ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*), { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram9 to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] + at llvm.dbg.composite11 = internal constant %llvm.dbg.composite.type { i32 458771, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([2 x i8]* @.str3, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 3, i64 8, i64 8, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array10 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at llvm.dbg.derivedtype12 = internal constant %llvm.dbg.derivedtype.type { i32 458767, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 64, i64 64, i64 0, i32 0, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite11 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] + at llvm.dbg.array13 = internal constant [2 x { }*] [{ }* null, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype12 to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] + at llvm.dbg.composite = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array13 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at llvm.dbg.subprogram14 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str7, i32 0, i32 0), i8* getelementptr ([4 x i8]* @.str7, i32 0, i32 0), i8* getelementptr ([12 x i8]* @.str8, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 7, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at _ZTI6Error1 = weak_odr constant %struct.__class_type_info_pseudo { %struct.__type_info_pseudo { i8* inttoptr (i64 add (i64 ptrtoint ([0 x i32 (...)*]* @_ZTVN10__cxxabiv117__class_type_infoE to i64), i64 16) to i8*), i8* getelementptr ([8 x i8]* @_ZTS6Error1, i32 0, i32 0) } } ; <%struct.__class_type_info_pseudo*> [#uses=1] + at _ZTVN10__cxxabiv117__class_type_infoE = external constant [0 x i32 (...)*] ; <[0 x i32 (...)*]*> [#uses=1] + at _ZTS6Error1 = weak_odr constant [8 x i8] c"6Error1\00" ; <[8 x i8]*> [#uses=1] + at _ZTI6Error2 = weak_odr constant %struct.__class_type_info_pseudo { %struct.__type_info_pseudo { i8* inttoptr (i64 add (i64 ptrtoint ([0 x i32 (...)*]* @_ZTVN10__cxxabiv117__class_type_infoE to i64), i64 16) to i8*), i8* getelementptr ([8 x i8]* @_ZTS6Error2, i32 0, i32 0) } } ; <%struct.__class_type_info_pseudo*> [#uses=1] + at _ZTS6Error2 = weak_odr constant [8 x i8] c"6Error2\00" ; <[8 x i8]*> [#uses=1] + +define void @_ZN1A3BarEv(%struct.A* %this) ssp { +entry: + tail call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram14 to { }*)) + tail call void @llvm.dbg.stoppoint(i32 9, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + invoke void @_ZN1A4FuncEv(%struct.A* %this) + to label %return unwind label %lpad + +bb: ; preds = %lpad + tail call void @llvm.dbg.stoppoint(i32 10, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %0 = tail call i8* @__cxa_begin_catch(i8* %eh_ptr) nounwind ; [#uses=0] + tail call void @__cxa_end_catch() + ret void + +return: ; preds = %entry + tail call void @llvm.dbg.stoppoint(i32 14, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + ret void + +lpad: ; preds = %entry + %eh_ptr = tail call i8* @llvm.eh.exception() ; [#uses=3] + tail call void @llvm.dbg.stoppoint(i32 14, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %eh_select = tail call i64 (i8*, i8*, ...)* @llvm.eh.selector.i64(i8* %eh_ptr, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (%struct.__class_type_info_pseudo* @_ZTI6Error1 to i8*), i8* bitcast (%struct.__class_type_info_pseudo* @_ZTI6Error2 to i8*), i8* null) ; [#uses=1] + %eh_typeid = tail call i64 @llvm.eh.typeid.for.i64(i8* bitcast (%struct.__class_type_info_pseudo* @_ZTI6Error1 to i8*)) ; [#uses=1] + %1 = icmp eq i64 %eh_select, %eh_typeid ; [#uses=1] + br i1 %1, label %bb, label %ppad7 + +ppad7: ; preds = %lpad + %eh_typeid8 = tail call i64 @llvm.eh.typeid.for.i64(i8* bitcast (%struct.__class_type_info_pseudo* @_ZTI6Error2 to i8*)) ; [#uses=0] + %2 = tail call i8* @__cxa_begin_catch(i8* %eh_ptr) nounwind ; [#uses=0] + tail call void @__cxa_end_catch() + ret void +} + +declare void @llvm.dbg.func.start({ }*) nounwind readnone + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind readnone + +declare void @_ZN1A4FuncEv(%struct.A*) + +declare i8* @__cxa_begin_catch(i8*) nounwind + +declare i8* @llvm.eh.exception() nounwind + +declare i64 @llvm.eh.selector.i64(i8*, i8*, ...) nounwind + +declare i64 @llvm.eh.typeid.for.i64(i8*) nounwind + +declare void @__cxa_end_catch() + +declare i32 @__gxx_personality_v0(...) From gohman at apple.com Mon Jun 15 13:38:59 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 18:38:59 -0000 Subject: [llvm-commits] [llvm] r73401 - /llvm/trunk/lib/Analysis/IVUsers.cpp Message-ID: <200906151838.n5FIcxns002287@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 13:38:59 2009 New Revision: 73401 URL: http://llvm.org/viewvc/llvm-project?rev=73401&view=rev Log: Code cleanups. getSCEVAtScope no longer uses SCEVCouldNotCompute. Modified: llvm/trunk/lib/Analysis/IVUsers.cpp Modified: llvm/trunk/lib/Analysis/IVUsers.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IVUsers.cpp?rev=73401&r1=73400&r2=73401&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IVUsers.cpp (original) +++ llvm/trunk/lib/Analysis/IVUsers.cpp Mon Jun 15 13:38:59 2009 @@ -120,9 +120,9 @@ // Use getSCEVAtScope to attempt to simplify other loops out of // the picture. SCEVHandle AddRecStart = AddRec->getStart(); - SCEVHandle BetterAddRecStart = SE->getSCEVAtScope(AddRecStart, UseLoop); - if (!isa(BetterAddRecStart)) - AddRecStart = BetterAddRecStart; + AddRecStart = SE->getSCEVAtScope(AddRecStart, UseLoop); + SCEVHandle AddRecStride = AddRec->getStepRecurrence(*SE); + AddRecStride = SE->getSCEVAtScope(AddRecStride, UseLoop); // FIXME: If Start contains an SCEVAddRecExpr from a different loop, other // than an outer loop of the current loop, reject it. LSR has no concept of @@ -136,18 +136,18 @@ Start = SE->getAddExpr(Start, AddRecStart); - if (!isa(AddRec->getStepRecurrence(*SE))) { - // If stride is an instruction, make sure it dominates the loop preheader. - // Otherwise we could end up with a use before def situation. + // If stride is an instruction, make sure it dominates the loop preheader. + // Otherwise we could end up with a use before def situation. + if (!isa(AddRecStride)) { BasicBlock *Preheader = L->getLoopPreheader(); - if (!AddRec->getStepRecurrence(*SE)->dominates(Preheader, DT)) + if (!AddRecStride->dominates(Preheader, DT)) return false; DOUT << "[" << L->getHeader()->getName() << "] Variable stride: " << *AddRec << "\n"; } - Stride = AddRec->getStepRecurrence(*SE); + Stride = AddRecStride; isSigned = isSExt; return true; } @@ -326,7 +326,7 @@ // Evaluate the expression out of the loop, if possible. if (!L->contains(U.getUser()->getParent())) { SCEVHandle ExitVal = SE->getSCEVAtScope(RetVal, L->getParentLoop()); - if (!isa(ExitVal) && ExitVal->isLoopInvariant(L)) + if (ExitVal->isLoopInvariant(L)) RetVal = ExitVal; } // Promote the result to the type of the use. From edwintorok at gmail.com Mon Jun 15 13:43:45 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Mon, 15 Jun 2009 21:43:45 +0300 Subject: [llvm-commits] [PATCH] Avoid use after free in ScalarEvolution In-Reply-To: <4AFCEFE6-6B21-4B33-998F-DACE37C5235E@apple.com> References: <4A16816C.7080405@gmail.com> <4AFCEFE6-6B21-4B33-998F-DACE37C5235E@apple.com> Message-ID: <4A369661.8050909@gmail.com> On 2009-06-15 21:15, Dan Gohman wrote: > Hi Edwin, > > WritingAnLLVMPass.htm's description of releaseMemory says "This method > is > called after the run* method for the class, before the next call of run* > in your pass." This suggests that it's a bug in the PassManager for not > calling releaseMemory for on-the-fly analyses. > Would it be OK with you if I file a PR, and then try to provide a patch to do that? And also add an assertion before calling run() that checks that releaseMemory was called. > On the other hand, I do see several other existing passes calling > releaseMemory or the equivalent at the top of their run functions. > If the passmanager will properly call releaseMemory, could we patch them not to do that? (And for passes that have a releaseMemory equivalent that isn;'t called that, rename it). Best regards, --Edwin From isanbard at gmail.com Mon Jun 15 14:10:56 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 15 Jun 2009 19:10:56 -0000 Subject: [llvm-commits] [llvm] r73404 - /llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll Message-ID: <200906151910.n5FJAu3p003336@zion.cs.uiuc.edu> Author: void Date: Mon Jun 15 14:10:56 2009 New Revision: 73404 URL: http://llvm.org/viewvc/llvm-project?rev=73404&view=rev Log: This test is failing. Revert for now. Removed: llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll Removed: llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll?rev=73403&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-06-15-tailmerge-crash-2.ll (removed) @@ -1,89 +0,0 @@ -; RUN: llvm-as < %s | llc -march=x86 -; -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" -target triple = "x86_64-apple-darwin10.0" - %llvm.dbg.anchor.type = type { i32, i32 } - %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8*, i32 } - %llvm.dbg.composite.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, { }*, { }*, i32 } - %llvm.dbg.derivedtype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, { }* } - %llvm.dbg.subprogram.type = type { i32, { }*, { }*, i8*, i8*, i8*, { }*, i32, { }*, i1, i1 } - %struct.A = type <{ i8 }> - %struct.__class_type_info_pseudo = type { %struct.__type_info_pseudo } - %struct.__type_info_pseudo = type { i8*, i8* } - at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] - at .str = internal constant [12 x i8] c"testcase.ii\00", section "llvm.metadata" ; <[12 x i8]*> [#uses=1] - at .str1 = internal constant [22 x i8] c"/Volumes/Sandbox/swb/\00", section "llvm.metadata" ; <[22 x i8]*> [#uses=1] - at .str2 = internal constant [57 x i8] c"4.2.1 (Based on Apple Inc. build 5646) (LLVM build 2110)\00", section "llvm.metadata" ; <[57 x i8]*> [#uses=1] - at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 4, i8* getelementptr ([12 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([22 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([57 x i8]* @.str2, i32 0, i32 0), i1 true, i1 true, i8* null, i32 0 }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] - at .str3 = internal constant [2 x i8] c"A\00", section "llvm.metadata" ; <[2 x i8]*> [#uses=1] - at llvm.dbg.derivedtype = internal constant %llvm.dbg.derivedtype.type { i32 458767, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 64, i64 64, i64 0, i32 0, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite11 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] - at llvm.dbg.array = internal constant [2 x { }*] [{ }* null, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] - at llvm.dbg.composite4 = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] - at llvm.dbg.subprograms = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 46 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] - at .str5 = internal constant [5 x i8] c"Func\00", section "llvm.metadata" ; <[5 x i8]*> [#uses=1] - at .str6 = internal constant [13 x i8] c"_ZN1A4FuncEv\00", section "llvm.metadata" ; <[13 x i8]*> [#uses=1] - at llvm.dbg.subprogram = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([5 x i8]* @.str5, i32 0, i32 0), i8* getelementptr ([5 x i8]* @.str5, i32 0, i32 0), i8* getelementptr ([13 x i8]* @.str6, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 4, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite4 to { }*), i1 false, i1 false }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] - at .str7 = internal constant [4 x i8] c"Bar\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] - at .str8 = internal constant [12 x i8] c"_ZN1A3BarEv\00", section "llvm.metadata" ; <[12 x i8]*> [#uses=1] - at llvm.dbg.subprogram9 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str7, i32 0, i32 0), i8* getelementptr ([4 x i8]* @.str7, i32 0, i32 0), i8* getelementptr ([12 x i8]* @.str8, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 7, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite4 to { }*), i1 false, i1 false }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] - at llvm.dbg.array10 = internal constant [2 x { }*] [{ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*), { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram9 to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] - at llvm.dbg.composite11 = internal constant %llvm.dbg.composite.type { i32 458771, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([2 x i8]* @.str3, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 3, i64 8, i64 8, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array10 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] - at llvm.dbg.derivedtype12 = internal constant %llvm.dbg.derivedtype.type { i32 458767, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 64, i64 64, i64 0, i32 0, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite11 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] - at llvm.dbg.array13 = internal constant [2 x { }*] [{ }* null, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype12 to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] - at llvm.dbg.composite = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array13 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] - at llvm.dbg.subprogram14 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str7, i32 0, i32 0), i8* getelementptr ([4 x i8]* @.str7, i32 0, i32 0), i8* getelementptr ([12 x i8]* @.str8, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 7, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] - at _ZTI6Error1 = weak_odr constant %struct.__class_type_info_pseudo { %struct.__type_info_pseudo { i8* inttoptr (i64 add (i64 ptrtoint ([0 x i32 (...)*]* @_ZTVN10__cxxabiv117__class_type_infoE to i64), i64 16) to i8*), i8* getelementptr ([8 x i8]* @_ZTS6Error1, i32 0, i32 0) } } ; <%struct.__class_type_info_pseudo*> [#uses=1] - at _ZTVN10__cxxabiv117__class_type_infoE = external constant [0 x i32 (...)*] ; <[0 x i32 (...)*]*> [#uses=1] - at _ZTS6Error1 = weak_odr constant [8 x i8] c"6Error1\00" ; <[8 x i8]*> [#uses=1] - at _ZTI6Error2 = weak_odr constant %struct.__class_type_info_pseudo { %struct.__type_info_pseudo { i8* inttoptr (i64 add (i64 ptrtoint ([0 x i32 (...)*]* @_ZTVN10__cxxabiv117__class_type_infoE to i64), i64 16) to i8*), i8* getelementptr ([8 x i8]* @_ZTS6Error2, i32 0, i32 0) } } ; <%struct.__class_type_info_pseudo*> [#uses=1] - at _ZTS6Error2 = weak_odr constant [8 x i8] c"6Error2\00" ; <[8 x i8]*> [#uses=1] - -define void @_ZN1A3BarEv(%struct.A* %this) ssp { -entry: - tail call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram14 to { }*)) - tail call void @llvm.dbg.stoppoint(i32 9, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) - invoke void @_ZN1A4FuncEv(%struct.A* %this) - to label %return unwind label %lpad - -bb: ; preds = %lpad - tail call void @llvm.dbg.stoppoint(i32 10, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) - %0 = tail call i8* @__cxa_begin_catch(i8* %eh_ptr) nounwind ; [#uses=0] - tail call void @__cxa_end_catch() - ret void - -return: ; preds = %entry - tail call void @llvm.dbg.stoppoint(i32 14, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) - ret void - -lpad: ; preds = %entry - %eh_ptr = tail call i8* @llvm.eh.exception() ; [#uses=3] - tail call void @llvm.dbg.stoppoint(i32 14, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) - %eh_select = tail call i64 (i8*, i8*, ...)* @llvm.eh.selector.i64(i8* %eh_ptr, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (%struct.__class_type_info_pseudo* @_ZTI6Error1 to i8*), i8* bitcast (%struct.__class_type_info_pseudo* @_ZTI6Error2 to i8*), i8* null) ; [#uses=1] - %eh_typeid = tail call i64 @llvm.eh.typeid.for.i64(i8* bitcast (%struct.__class_type_info_pseudo* @_ZTI6Error1 to i8*)) ; [#uses=1] - %1 = icmp eq i64 %eh_select, %eh_typeid ; [#uses=1] - br i1 %1, label %bb, label %ppad7 - -ppad7: ; preds = %lpad - %eh_typeid8 = tail call i64 @llvm.eh.typeid.for.i64(i8* bitcast (%struct.__class_type_info_pseudo* @_ZTI6Error2 to i8*)) ; [#uses=0] - %2 = tail call i8* @__cxa_begin_catch(i8* %eh_ptr) nounwind ; [#uses=0] - tail call void @__cxa_end_catch() - ret void -} - -declare void @llvm.dbg.func.start({ }*) nounwind readnone - -declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind readnone - -declare void @_ZN1A4FuncEv(%struct.A*) - -declare i8* @__cxa_begin_catch(i8*) nounwind - -declare i8* @llvm.eh.exception() nounwind - -declare i64 @llvm.eh.selector.i64(i8*, i8*, ...) nounwind - -declare i64 @llvm.eh.typeid.for.i64(i8*) nounwind - -declare void @__cxa_end_catch() - -declare i32 @__gxx_personality_v0(...) From baldrick at free.fr Mon Jun 15 14:31:46 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 15 Jun 2009 21:31:46 +0200 Subject: [llvm-commits] [llvm] r73394 - /llvm/trunk/docs/LangRef.html In-Reply-To: <200906151737.n5FHbA71032426@zion.cs.uiuc.edu> References: <200906151737.n5FHbA71032426@zion.cs.uiuc.edu> Message-ID: <4A36A1A2.8050400@free.fr> Hi Dan, > -
    This attribute indicates that the code generator should not enforce red zone > -mandated by target specific ABI.
    > +
    This attribute indicates that the code generator should not use a > +red zone, even if it would otherwise be supported by the target-specific ABI. > +
    I personally found the original clearer. I'm not sure what it means for an ABI to support something; and the phrase seems to contain several negations ("should not", "would otherwise") which left me confused. Ciao, Duncan. From evan.cheng at apple.com Mon Jun 15 14:36:34 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 15 Jun 2009 19:36:34 -0000 Subject: [llvm-commits] [llvm] r73406 - /llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Message-ID: <200906151936.n5FJaYCH004474@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jun 15 14:36:32 2009 New Revision: 73406 URL: http://llvm.org/viewvc/llvm-project?rev=73406&view=rev Log: Silence a warning. Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=73406&r1=73405&r2=73406&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Mon Jun 15 14:36:32 2009 @@ -1111,7 +1111,7 @@ // Form the pair instruction instead. unsigned EvenReg = 0, OddReg = 0; unsigned BaseReg = 0, OffReg = 0, PredReg = 0; - ARMCC::CondCodes Pred; + ARMCC::CondCodes Pred = ARMCC::AL; DebugLoc dl; for (unsigned i = 0; i != NumMove; ++i) { MachineInstr *Op = Ops.back(); From isanbard at gmail.com Mon Jun 15 14:39:04 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 15 Jun 2009 19:39:04 -0000 Subject: [llvm-commits] [llvm] r73407 - in /llvm/trunk/lib/Target/X86: X86Instr64bit.td X86InstrInfo.td Message-ID: <200906151939.n5FJd4q3004562@zion.cs.uiuc.edu> Author: void Date: Mon Jun 15 14:39:04 2009 New Revision: 73407 URL: http://llvm.org/viewvc/llvm-project?rev=73407&view=rev Log: "The Intel instruction tables should include the 64-bit and 32-bit instructions that push immediate operands of 1, 2, and 4 bytes (extended to the native register size in each case). The assembly mnemonics are "pushl" and "pushq." One such instruction appears at the beginning of the "start" function , so this is essential for accurate disassembly when unwinding." Patch by Sean Callanan! Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=73407&r1=73406&r2=73407&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Jun 15 14:39:04 2009 @@ -177,6 +177,15 @@ (outs), (ins GR64:$reg), "push{q}\t$reg", []>; } +let Defs = [RSP], Uses = [RSP], neverHasSideEffects = 1, mayStore = 1 in { +def PUSH64i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm), + "push{l}\t$imm", []>; +def PUSH64i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm), + "push{l}\t$imm", []>; +def PUSH64i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm), + "push{l}\t$imm", []>; +} + let Defs = [RSP, EFLAGS], Uses = [RSP], mayLoad = 1 in def POPFQ : I<0x9D, RawFrm, (outs), (ins), "popf", []>, REX_W; let Defs = [RSP], Uses = [RSP, EFLAGS], mayStore = 1 in Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=73407&r1=73406&r2=73407&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jun 15 14:39:04 2009 @@ -611,6 +611,15 @@ def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>; } +let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in { +def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm), + "push{q}\t$imm", []>; +def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm), + "push{q}\t$imm", []>; +def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm), + "push{q}\t$imm", []>; +} + let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>; let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in From gohman at apple.com Mon Jun 15 15:23:09 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 13:23:09 -0700 Subject: [llvm-commits] [PATCH] Avoid use after free in ScalarEvolution In-Reply-To: <4A369661.8050909@gmail.com> References: <4A16816C.7080405@gmail.com> <4AFCEFE6-6B21-4B33-998F-DACE37C5235E@apple.com> <4A369661.8050909@gmail.com> Message-ID: <2BDFCF40-1E6F-47E3-917D-E1148DE31CF7@apple.com> On Jun 15, 2009, at 11:43 AM, T?r?k Edwin wrote: > On 2009-06-15 21:15, Dan Gohman wrote: > >> Hi Edwin, >> >> >> >> WritingAnLLVMPass.htm's description of releaseMemory says "This >> method >> >> is >> >> called after the run* method for the class, before the next call of >> run* >> >> in your pass." This suggests that it's a bug in the PassManager >> for not >> >> calling releaseMemory for on-the-fly analyses. >> >> >> > > Would it be OK with you if I file a PR, and then try to provide a > patch > to do that? > And also add an assertion before calling run() that checks that > releaseMemory was called. Sounds good to me. > > >> On the other hand, I do see several other existing passes calling >> >> releaseMemory or the equivalent at the top of their run functions. >> >> >> > > If the passmanager will properly call releaseMemory, could we patch > them > not to do that? > (And for passes that have a releaseMemory equivalent that isn;'t > called > that, rename it). Sure. Dan From resistor at mac.com Mon Jun 15 15:50:26 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 15 Jun 2009 20:50:26 -0000 Subject: [llvm-commits] [llvm] r73412 - in /llvm/trunk: ./ lib/Transforms/IPO/PartialInlining.cpp Message-ID: <200906152050.n5FKoR58007658@zion.cs.uiuc.edu> Author: resistor Date: Mon Jun 15 15:50:26 2009 New Revision: 73412 URL: http://llvm.org/viewvc/llvm-project?rev=73412&view=rev Log: Merge PartialInliner changes. Modified: llvm/trunk/ (props changed) llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp Propchange: llvm/trunk/ ------------------------------------------------------------------------------ bzr:see-revprops = 73412 Modified: llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp?rev=73412&r1=73411&r2=73412&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp Mon Jun 15 15:50:26 2009 @@ -20,10 +20,13 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/FunctionUtils.h" +#include "llvm/ADT/Statistic.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/CFG.h" using namespace llvm; +STATISTIC(NumPartialInlined, "Number of functions partially inlined"); + namespace { struct VISIBILITY_HIDDEN PartialInliner : public ModulePass { virtual void getAnalysisUsage(AnalysisUsage &AU) const { } @@ -132,6 +135,8 @@ duplicateFunction->replaceAllUsesWith(F); duplicateFunction->eraseFromParent(); + ++NumPartialInlined; + return extractedFunction; } From evan.cheng at apple.com Mon Jun 15 15:54:56 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 15 Jun 2009 20:54:56 -0000 Subject: [llvm-commits] [llvm] r73413 - /llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Message-ID: <200906152054.n5FKsvCF007800@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jun 15 15:54:56 2009 New Revision: 73413 URL: http://llvm.org/viewvc/llvm-project?rev=73413&view=rev Log: Do not form ldrd / strd if the two dests / srcs are the same. Code clean up. Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=73413&r1=73412&r2=73413&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Mon Jun 15 15:54:56 2009 @@ -937,7 +937,11 @@ } private: - bool SatisfyLdStDWordlignment(MachineInstr *MI); + bool CanFormLdStDWord(MachineInstr *Op0, MachineInstr *Op1, DebugLoc &dl, + unsigned &NewOpc, unsigned &EvenReg, + unsigned &OddReg, unsigned &BaseReg, + unsigned &OffReg, unsigned &Offset, + unsigned &PredReg, ARMCC::CondCodes &Pred); bool RescheduleOps(MachineBasicBlock *MBB, SmallVector &Ops, unsigned Base, bool isLd, @@ -995,16 +999,55 @@ return true; } -bool ARMPreAllocLoadStoreOpt::SatisfyLdStDWordlignment(MachineInstr *MI) { - if (!MI->hasOneMemOperand() || - !MI->memoperands_begin()->getValue() || - MI->memoperands_begin()->isVolatile()) +bool +ARMPreAllocLoadStoreOpt::CanFormLdStDWord(MachineInstr *Op0, MachineInstr *Op1, + DebugLoc &dl, + unsigned &NewOpc, unsigned &EvenReg, + unsigned &OddReg, unsigned &BaseReg, + unsigned &OffReg, unsigned &Offset, + unsigned &PredReg, + ARMCC::CondCodes &Pred) { + // FIXME: FLDS / FSTS -> FLDD / FSTD + unsigned Opcode = Op0->getOpcode(); + if (Opcode == ARM::LDR) + NewOpc = ARM::LDRD; + else if (Opcode == ARM::STR) + NewOpc = ARM::STRD; + else + return 0; + + // Must sure the base address satisfies i64 ld / st alignment requirement. + if (!Op0->hasOneMemOperand() || + !Op0->memoperands_begin()->getValue() || + Op0->memoperands_begin()->isVolatile()) return false; - unsigned Align = MI->memoperands_begin()->getAlignment(); + unsigned Align = Op0->memoperands_begin()->getAlignment(); unsigned ReqAlign = STI->hasV6Ops() ? TD->getPrefTypeAlignment(Type::Int64Ty) : 8; // Pre-v6 need 8-byte align - return Align >= ReqAlign; + if (Align < ReqAlign) + return false; + + // Then make sure the immediate offset fits. + int OffImm = getMemoryOpOffset(Op0); + ARM_AM::AddrOpc AddSub = ARM_AM::add; + if (OffImm < 0) { + AddSub = ARM_AM::sub; + OffImm = - OffImm; + } + if (OffImm >= 256) // 8 bits + return false; + Offset = ARM_AM::getAM3Opc(AddSub, OffImm); + + EvenReg = Op0->getOperand(0).getReg(); + OddReg = Op0->getOperand(1).getReg(); + if (EvenReg == OddReg) + return false; + BaseReg = Op0->getOperand(1).getReg(); + OffReg = Op0->getOperand(2).getReg(); + Pred = getInstrPredicate(Op0, PredReg); + dl = Op0->getDebugLoc(); + return true; } bool ARMPreAllocLoadStoreOpt::RescheduleOps(MachineBasicBlock *MBB, @@ -1075,66 +1118,31 @@ // If we are moving a pair of loads / stores, see if it makes sense // to try to allocate a pair of registers that can form register pairs. - unsigned PairOpcode = 0; + MachineInstr *Op0 = Ops.back(); + MachineInstr *Op1 = Ops[Ops.size()-2]; + unsigned EvenReg = 0, OddReg = 0; + unsigned BaseReg = 0, OffReg = 0, PredReg = 0; + ARMCC::CondCodes Pred = ARMCC::AL; + unsigned NewOpc = 0; unsigned Offset = 0; + DebugLoc dl; + if (NumMove == 2 && CanFormLdStDWord(Op0, Op1, dl, NewOpc, + EvenReg, OddReg, BaseReg, OffReg, + Offset, PredReg, Pred)) { + Ops.pop_back(); + Ops.pop_back(); + MBB->erase(Op0); + MBB->erase(Op1); - // Make sure the alignment requirement is met. - if (NumMove == 2 && SatisfyLdStDWordlignment(Ops.back())) { - int Opcode = Ops.back()->getOpcode(); - // FIXME: FLDS / FSTS -> FLDD / FSTD - if (Opcode == ARM::LDR) - PairOpcode = ARM::LDRD; - else if (Opcode == ARM::STR) - PairOpcode = ARM::STRD; - } - // Then make sure the immediate offset fits. - if (PairOpcode) { - int OffImm = getMemoryOpOffset(Ops.back()); - ARM_AM::AddrOpc AddSub = ARM_AM::add; - if (OffImm < 0) { - AddSub = ARM_AM::sub; - OffImm = - OffImm; - } - if (OffImm >= 256) // 8 bits - PairOpcode = 0; - else - Offset = ARM_AM::getAM3Opc(AddSub, OffImm); - } - - if (!PairOpcode) { - for (unsigned i = 0; i != NumMove; ++i) { - MachineInstr *Op = Ops.back(); - Ops.pop_back(); - MBB->splice(InsertPos, MBB, Op); - } - } else { - // Form the pair instruction instead. - unsigned EvenReg = 0, OddReg = 0; - unsigned BaseReg = 0, OffReg = 0, PredReg = 0; - ARMCC::CondCodes Pred = ARMCC::AL; - DebugLoc dl; - for (unsigned i = 0; i != NumMove; ++i) { - MachineInstr *Op = Ops.back(); - Ops.pop_back(); - unsigned Reg = Op->getOperand(0).getReg(); - if (i == 0) { - EvenReg = Reg; - BaseReg = Op->getOperand(1).getReg(); - OffReg = Op->getOperand(2).getReg(); - Pred = getInstrPredicate(Op, PredReg); - dl = Op->getDebugLoc(); - } else - OddReg = Reg; - MBB->erase(Op); - } + // Form the pair instruction. if (isLd) - BuildMI(*MBB, InsertPos, dl, TII->get(PairOpcode)) + BuildMI(*MBB, InsertPos, dl, TII->get(NewOpc)) .addReg(EvenReg, RegState::Define) .addReg(OddReg, RegState::Define) .addReg(BaseReg).addReg(0).addImm(Offset) .addImm(Pred).addReg(PredReg); else - BuildMI(*MBB, InsertPos, dl, TII->get(PairOpcode)) + BuildMI(*MBB, InsertPos, dl, TII->get(NewOpc)) .addReg(EvenReg) .addReg(OddReg) .addReg(BaseReg).addReg(0).addImm(Offset) @@ -1143,6 +1151,12 @@ // Add register allocation hints to form register pairs. MRI->setRegAllocationHint(EvenReg, ARMRI::RegPairEven, OddReg); MRI->setRegAllocationHint(OddReg, ARMRI::RegPairOdd, EvenReg); + } else { + for (unsigned i = 0; i != NumMove; ++i) { + MachineInstr *Op = Ops.back(); + Ops.pop_back(); + MBB->splice(InsertPos, MBB, Op); + } } NumLdStMoved += NumMove; From dalej at apple.com Mon Jun 15 15:59:27 2009 From: dalej at apple.com (Dale Johannesen) Date: Mon, 15 Jun 2009 20:59:27 -0000 Subject: [llvm-commits] [llvm] r73416 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll Message-ID: <200906152059.n5FKxSGA007976@zion.cs.uiuc.edu> Author: johannes Date: Mon Jun 15 15:59:27 2009 New Revision: 73416 URL: http://llvm.org/viewvc/llvm-project?rev=73416&view=rev Log: Fix the crash in this test. This is basically the same problem addressed in 31284, but the patch there only addressed the case where an invoke is the first thing in a block. Added: llvm/trunk/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.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=73416&r1=73415&r2=73416&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Jun 15 15:59:27 2009 @@ -859,6 +859,26 @@ return Changed; } +// isSafeToHoistInvoke - If we would need to insert a select that uses the +// value of this invoke (comments in HoistThenElseCodeToIf explain why we +// would need to do this), we can't hoist the invoke, as there is nowhere +// to put the select in this case. +static bool isSafeToHoistInvoke(BasicBlock *BB1, BasicBlock *BB2, + Instruction *I1, Instruction *I2) { + for (succ_iterator SI = succ_begin(BB1), E = succ_end(BB1); SI != E; ++SI) { + PHINode *PN; + for (BasicBlock::iterator BBI = SI->begin(); + (PN = dyn_cast(BBI)); ++BBI) { + Value *BB1V = PN->getIncomingValueForBlock(BB1); + Value *BB2V = PN->getIncomingValueForBlock(BB2); + if (BB1V != BB2V && (BB1V==I1 || BB2V==I2)) { + return false; + } + } + } + return true; +} + /// HoistThenElseCodeToIf - Given a conditional branch that goes to BB1 and /// BB2, hoist any common code in the two blocks up into the branch block. The /// caller of this function guarantees that BI's block dominates BB1 and BB2. @@ -879,8 +899,9 @@ I1 = BB1_Itr++; while (isa(I2)) I2 = BB2_Itr++; - if (I1->getOpcode() != I2->getOpcode() || isa(I1) || - isa(I1) || !I1->isIdenticalTo(I2)) + if (I1->getOpcode() != I2->getOpcode() || isa(I1) || + !I1->isIdenticalTo(I2) || + (isa(I1) && !isSafeToHoistInvoke(BB1, BB2, I1, I2))) return false; // If we get here, we can hoist at least one instruction. @@ -911,6 +932,10 @@ return true; HoistTerminator: + // It may not be possible to hoist an invoke. + if (isa(I1) && !isSafeToHoistInvoke(BB1, BB2, I1, I2)) + return true; + // Okay, it is safe to hoist the terminator. Instruction *NT = I1->clone(); BIParent->getInstList().insert(BI, NT); Added: llvm/trunk/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll?rev=73416&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll (added) +++ llvm/trunk/test/Transforms/SimplifyCFG/2009-06-15-InvokeCrash.ll Mon Jun 15 15:59:27 2009 @@ -0,0 +1,557 @@ +; RUN: llvm-as < %s | opt -simplifycfg -disable-output +; END. + %struct..4._102 = type { %struct.QVectorData* } + %struct..5._125 = type { %struct.QMapData* } + %struct.QAbstractTextDocumentLayout = type { %struct.QObject } + %struct.QBasicAtomic = type { i32 } + %struct.QFont = type { %struct.QFontPrivate*, i32 } + %struct.QFontMetrics = type { %struct.QFontPrivate* } + %struct.QFontPrivate = type opaque + %"struct.QFragmentMap" = type { %struct.QFragmentMapData } + %struct.QFragmentMapData = type { %"struct.QFragmentMapData::._154", i32 } + %"struct.QFragmentMapData::._154" = type { %"struct.QFragmentMapData::Header"* } + %"struct.QFragmentMapData::Header" = type { i32, i32, i32, i32, i32, i32, i32, i32 } + %"struct.QHash" = type { %"struct.QHash::._152" } + %"struct.QHash::._152" = type { %struct.QHashData* } + %struct.QHashData = type { %"struct.QHashData::Node"*, %"struct.QHashData::Node"**, %struct.QBasicAtomic, i32, i32, i16, i16, i32, i8 } + %"struct.QHashData::Node" = type { %"struct.QHashData::Node"*, i32 } + %"struct.QList::._92" = type { %struct.QListData } + %"struct.QList >" = type { %"struct.QList::._92" } + %struct.QListData = type { %"struct.QListData::Data"* } + %"struct.QListData::Data" = type { %struct.QBasicAtomic, i32, i32, i32, i8, [1 x i8*] } + %"struct.QMap" = type { %struct..5._125 } + %struct.QMapData = type { %"struct.QMapData::Node"*, [12 x %"struct.QMapData::Node"*], %struct.QBasicAtomic, i32, i32, i32, i8 } + %"struct.QMapData::Node" = type { %"struct.QMapData::Node"*, [1 x %"struct.QMapData::Node"*] } + %struct.QObject = type { i32 (...)**, %struct.QObjectData* } + %struct.QObjectData = type { i32 (...)**, %struct.QObject*, %struct.QObject*, %"struct.QList >", i8, [3 x i8], i32, i32 } + %struct.QObjectPrivate = type { %struct.QObjectData, i32, %struct.QObject*, %"struct.QList >", %"struct.QVector", %struct.QString } + %struct.QPaintDevice = type { i32 (...)**, i16 } + %struct.QPainter = type { %struct.QPainterPrivate* } + %struct.QPainterPrivate = type opaque + %struct.QPointF = type { double, double } + %struct.QPrinter = type { %struct.QPaintDevice, %struct.QPrinterPrivate* } + %struct.QPrinterPrivate = type opaque + %struct.QRectF = type { double, double, double, double } + %"struct.QSet" = type { %"struct.QHash" } + %"struct.QSharedDataPointer" = type { %struct.QTextFormatPrivate* } + %struct.QString = type { %"struct.QString::Data"* } + %"struct.QString::Data" = type { %struct.QBasicAtomic, i32, i32, i16*, i8, i8, [1 x i16] } + %struct.QTextBlockFormat = type { %struct.QTextFormat } + %struct.QTextBlockGroup = type { %struct.QAbstractTextDocumentLayout } + %struct.QTextDocumentConfig = type { %struct.QString } + %struct.QTextDocumentPrivate = type { %struct.QObjectPrivate, %struct.QString, %"struct.QVector", i1, i32, i32, i1, i32, i32, i32, i32, i1, %struct.QTextFormatCollection, %struct.QTextBlockGroup*, %struct.QAbstractTextDocumentLayout*, %"struct.QFragmentMap", %"struct.QFragmentMap", i32, %"struct.QList >", %"struct.QList >", %"struct.QMap", %"struct.QMap", %"struct.QMap", %struct.QTextDocumentConfig, i1, i1, %struct.QPointF } + %struct.QTextFormat = type { %"struct.QSharedDataPointer", i32 } + %struct.QTextFormatCollection = type { %"struct.QVector", %"struct.QVector", %"struct.QSet", %struct.QFont } + %struct.QTextFormatPrivate = type opaque + %"struct.QVector" = type { %struct..4._102 } + %struct.QVectorData = type { %struct.QBasicAtomic, i32, i32, i8 } + +define void @_ZNK13QTextDocument5printEP8QPrinter(%struct.QAbstractTextDocumentLayout* %this, %struct.QPrinter* %printer) { +entry: + %tmp = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] + %tmp.upgrd.1 = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=5] + %tmp2 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3] + %tmp.upgrd.2 = alloca %struct.QFontMetrics, align 16 ; <%struct.QFontMetrics*> [#uses=4] + %tmp.upgrd.3 = alloca %struct.QFont, align 16 ; <%struct.QFont*> [#uses=4] + %tmp3 = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=2] + %p = alloca %struct.QPainter, align 16 ; <%struct.QPainter*> [#uses=14] + %body = alloca %struct.QRectF, align 16 ; <%struct.QRectF*> [#uses=9] + %foo = alloca double, align 8 + %bar = alloca double, align 8 + %pageNumberPos = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=4] + %scaledPageSize = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=6] + %printerPageSize = alloca %struct.QPointF, align 16 ; <%struct.QPointF*> [#uses=3] + %fmt = alloca %struct.QTextBlockFormat, align 16 ; <%struct.QTextBlockFormat*> [#uses=5] + %font = alloca %struct.QFont, align 16 ; <%struct.QFont*> [#uses=5] + %tmp.upgrd.4 = call %struct.QTextDocumentPrivate* @_ZNK13QTextDocument6d_funcEv( %struct.QAbstractTextDocumentLayout* %this ) ; <%struct.QTextDocumentPrivate*> [#uses=5] + %tmp.upgrd.5 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + call void @_ZN8QPainterC1EP12QPaintDevice( %struct.QPainter* %p, %struct.QPaintDevice* %tmp.upgrd.5 ) + %tmp.upgrd.6 = invoke i1 @_ZNK8QPainter8isActiveEv( %struct.QPainter* %p ) + to label %invcont unwind label %cleanup329 ; [#uses=1] +invcont: ; preds = %entry + br i1 %tmp.upgrd.6, label %cond_next, label %cleanup328 +cond_next: ; preds = %invcont + %tmp8 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %this ) + to label %invcont7 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=0] +invcont7: ; preds = %cond_next + %tmp10 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] + call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp, double 0.000000e+00, double 0.000000e+00 ) + call void @_ZN6QRectFC1ERK7QPointFRK6QSizeF( %struct.QRectF* %body, %struct.QPointF* %tmp, %struct.QPointF* %tmp10 ) + call void @_ZN7QPointFC1Ev( %struct.QPointF* %pageNumberPos ) + %tmp12 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] + %tmp13 = call i1 @_ZNK6QSizeF7isValidEv( %struct.QPointF* %tmp12 ) ; [#uses=1] + br i1 %tmp13, label %cond_next15, label %bb +cond_next15: ; preds = %invcont7 + %tmp17 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26 ; <%struct.QPointF*> [#uses=1] + %tmp.upgrd.7 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %tmp17 ) ; [#uses=1] + %tmp18 = fcmp oeq double %tmp.upgrd.7, 0x41DFFFFFFFC00000 ; [#uses=1] + br i1 %tmp18, label %bb, label %cond_next20 +cond_next20: ; preds = %cond_next15 + br label %bb21 +bb: ; preds = %cond_next15, %invcont7 + br label %bb21 +bb21: ; preds = %bb, %cond_next20 + %iftmp.406.0 = phi i1 [ false, %bb ], [ true, %cond_next20 ] ; [#uses=1] + br i1 %iftmp.406.0, label %cond_true24, label %cond_false +cond_true24: ; preds = %bb21 + %tmp.upgrd.8 = invoke i32 @_Z13qt_defaultDpiv( ) + to label %invcont25 unwind label %cleanup329 ; [#uses=1] +invcont25: ; preds = %cond_true24 + %tmp26 = sitofp i32 %tmp.upgrd.8 to double ; [#uses=2] + %tmp30 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %this ) + to label %invcont29 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=1] +invcont29: ; preds = %invcont25 + %tmp32 = invoke %struct.QPaintDevice* @_ZNK27QAbstractTextDocumentLayout11paintDeviceEv( %struct.QAbstractTextDocumentLayout* %tmp30 ) + to label %invcont31 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=3] +invcont31: ; preds = %invcont29 + %tmp34 = icmp eq %struct.QPaintDevice* %tmp32, null ; [#uses=1] + br i1 %tmp34, label %cond_next42, label %cond_true35 +cond_true35: ; preds = %invcont31 + %tmp38 = invoke i32 @_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp32 ) + to label %invcont37 unwind label %cleanup329 ; [#uses=1] +invcont37: ; preds = %cond_true35 + %tmp38.upgrd.9 = sitofp i32 %tmp38 to double ; [#uses=1] + %tmp41 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp32 ) + to label %invcont40 unwind label %cleanup329 ; [#uses=1] +invcont40: ; preds = %invcont37 + %tmp41.upgrd.10 = sitofp i32 %tmp41 to double ; [#uses=1] + br label %cond_next42 +cond_next42: ; preds = %invcont40, %invcont31 + %sourceDpiY.2 = phi double [ %tmp41.upgrd.10, %invcont40 ], [ %tmp26, %invcont31 ] ; [#uses=1] + %sourceDpiX.2 = phi double [ %tmp38.upgrd.9, %invcont40 ], [ %tmp26, %invcont31 ] ; [#uses=1] + %tmp44 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp46 = invoke i32 @_ZNK12QPaintDevice11logicalDpiXEv( %struct.QPaintDevice* %tmp44 ) + to label %invcont45 unwind label %cleanup329 ; [#uses=1] +invcont45: ; preds = %cond_next42 + %tmp46.upgrd.11 = sitofp i32 %tmp46 to double ; [#uses=1] + %tmp48 = fdiv double %tmp46.upgrd.11, %sourceDpiX.2 ; [#uses=2] + %tmp50 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp52 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp50 ) + to label %invcont51 unwind label %cleanup329 ; [#uses=1] +invcont51: ; preds = %invcont45 + %tmp52.upgrd.12 = sitofp i32 %tmp52 to double ; [#uses=1] + %tmp54 = fdiv double %tmp52.upgrd.12, %sourceDpiY.2 ; [#uses=2] + invoke void @_ZN8QPainter5scaleEdd( %struct.QPainter* %p, double %tmp48, double %tmp54 ) + to label %invcont57 unwind label %cleanup329 +invcont57: ; preds = %invcont51 + %tmp.upgrd.13 = getelementptr %struct.QPointF* %scaledPageSize, i32 0, i32 0 ; [#uses=1] + %tmp60 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26, i32 0 ; [#uses=1] + %tmp61 = load double* %tmp60 ; [#uses=1] + store double %tmp61, double* %tmp.upgrd.13 + %tmp62 = getelementptr %struct.QPointF* %scaledPageSize, i32 0, i32 1 ; [#uses=1] + %tmp63 = getelementptr %struct.QTextDocumentPrivate* %tmp.upgrd.4, i32 0, i32 26, i32 1 ; [#uses=1] + %tmp64 = load double* %tmp63 ; [#uses=1] + store double %tmp64, double* %tmp62 + %tmp65 = call double* @_ZN6QSizeF6rwidthEv( %struct.QPointF* %scaledPageSize ) ; [#uses=2] + %tmp67 = load double* %tmp65 ; [#uses=1] + %tmp69 = mul double %tmp67, %tmp48 ; [#uses=1] + store double %tmp69, double* %tmp65 + %tmp71 = call double* @_ZN6QSizeF7rheightEv( %struct.QPointF* %scaledPageSize ) ; [#uses=2] + %tmp73 = load double* %tmp71 ; [#uses=1] + %tmp75 = mul double %tmp73, %tmp54 ; [#uses=1] + store double %tmp75, double* %tmp71 + %tmp78 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp80 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp78 ) + to label %invcont79 unwind label %cleanup329 ; [#uses=1] +invcont79: ; preds = %invcont57 + %tmp82 = getelementptr %struct.QPrinter* %printer, i32 0, i32 0 ; <%struct.QPaintDevice*> [#uses=1] + %tmp84 = invoke i32 @_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp82 ) + to label %invcont83 unwind label %cleanup329 ; [#uses=1] +invcont83: ; preds = %invcont79 + %tmp80.upgrd.14 = sitofp i32 %tmp80 to double ; [#uses=1] + %tmp84.upgrd.15 = sitofp i32 %tmp84 to double ; [#uses=1] + call void @_ZN6QSizeFC1Edd( %struct.QPointF* %printerPageSize, double %tmp84.upgrd.15, double %tmp80.upgrd.14 ) + %tmp85 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %printerPageSize ) ; [#uses=1] + %tmp86 = call double @_ZNK6QSizeF6heightEv( %struct.QPointF* %scaledPageSize ) ; [#uses=1] + %tmp87 = fdiv double %tmp85, %tmp86 ; [#uses=1] + %tmp88 = call double @_ZNK6QSizeF5widthEv( %struct.QPointF* %printerPageSize ) ; [#uses=1] + %tmp89 = call double @_ZNK6QSizeF5widthEv( %struct.QPointF* %scaledPageSize ) ; [#uses=1] + %tmp90 = fdiv double %tmp88, %tmp89 ; [#uses=1] + invoke void @_ZN8QPainter5scaleEdd( %struct.QPainter* %p, double %tmp90, double %tmp87 ) + to label %cond_next194 unwind label %cleanup329 +cond_false: ; preds = %bb21 + %tmp.upgrd.16 = getelementptr %struct.QAbstractTextDocumentLayout* %this, i32 0, i32 0 ; <%struct.QObject*> [#uses=1] + %tmp95 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument5cloneEP7QObject( %struct.QAbstractTextDocumentLayout* %this, %struct.QObject* %tmp.upgrd.16 ) + to label %invcont94 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=9] +invcont94: ; preds = %cond_false + %tmp99 = invoke %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) + to label %invcont98 unwind label %cleanup329 ; <%struct.QAbstractTextDocumentLayout*> [#uses=1] +invcont98: ; preds = %invcont94 + %tmp101 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont100 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=1] +invcont100: ; preds = %invcont98 + invoke void @_ZN27QAbstractTextDocumentLayout14setPaintDeviceEP12QPaintDevice( %struct.QAbstractTextDocumentLayout* %tmp99, %struct.QPaintDevice* %tmp101 ) + to label %invcont103 unwind label %cleanup329 +invcont103: ; preds = %invcont100 + %tmp105 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont104 unwind label %cleanup329 ; <%struct.QPaintDevice*> [#uses=1] +invcont104: ; preds = %invcont103 + %tmp107 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp105 ) + to label %invcont106 unwind label %cleanup329 ; [#uses=1] +invcont106: ; preds = %invcont104 + %tmp108 = sitofp i32 %tmp107 to double ; [#uses=1] + %tmp109 = mul double %tmp108, 0x3FE93264C993264C ; [#uses=1] + %tmp109.upgrd.17 = fptosi double %tmp109 to i32 ; [#uses=3] + %tmp.upgrd.18 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1] + invoke void @_ZNK10QTextFrame11frameFormatEv( %struct.QTextBlockFormat* sret %fmt, %struct.QTextBlockGroup* %tmp.upgrd.18 ) + to label %invcont111 unwind label %cleanup329 +invcont111: ; preds = %invcont106 + %tmp112 = sitofp i32 %tmp109.upgrd.17 to double ; [#uses=1] + invoke void @_ZN16QTextFrameFormat9setMarginEd( %struct.QTextBlockFormat* %fmt, double %tmp112 ) + to label %invcont114 unwind label %cleanup192 +invcont114: ; preds = %invcont111 + %tmp116 = call %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv( %struct.QAbstractTextDocumentLayout* %tmp95 ) ; <%struct.QTextBlockGroup*> [#uses=1] + invoke void @_ZN10QTextFrame14setFrameFormatERK16QTextFrameFormat( %struct.QTextBlockGroup* %tmp116, %struct.QTextBlockFormat* %fmt ) + to label %invcont117 unwind label %cleanup192 +invcont117: ; preds = %invcont114 + %tmp119 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont118 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] +invcont118: ; preds = %invcont117 + %tmp121 = invoke i32 @_ZNK12QPaintDevice6heightEv( %struct.QPaintDevice* %tmp119 ) + to label %invcont120 unwind label %cleanup192 ; [#uses=1] +invcont120: ; preds = %invcont118 + %tmp121.upgrd.19 = sitofp i32 %tmp121 to double ; [#uses=1] + %tmp123 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont122 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] +invcont122: ; preds = %invcont120 + %tmp125 = invoke i32 @_ZNK12QPaintDevice5widthEv( %struct.QPaintDevice* %tmp123 ) + to label %invcont124 unwind label %cleanup192 ; [#uses=1] +invcont124: ; preds = %invcont122 + %tmp125.upgrd.20 = sitofp i32 %tmp125 to double ; [#uses=1] + call void @_ZN6QRectFC1Edddd( %struct.QRectF* %tmp.upgrd.1, double 0.000000e+00, double 0.000000e+00, double %tmp125.upgrd.20, double %tmp121.upgrd.19 ) + %tmp126 = getelementptr %struct.QRectF* %body, i32 0, i32 0 ; [#uses=1] + %tmp127 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 0 ; [#uses=1] + %tmp128 = load double* %tmp127 ; [#uses=1] + store double %tmp128, double* %tmp126 + %tmp129 = getelementptr %struct.QRectF* %body, i32 0, i32 1 ; [#uses=1] + %tmp130 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 1 ; [#uses=1] + %tmp131 = load double* %tmp130 ; [#uses=1] + store double %tmp131, double* %tmp129 + %tmp132 = getelementptr %struct.QRectF* %body, i32 0, i32 2 ; [#uses=1] + %tmp133 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 2 ; [#uses=1] + %tmp134 = load double* %tmp133 ; [#uses=1] + store double %tmp134, double* %tmp132 + %tmp135 = getelementptr %struct.QRectF* %body, i32 0, i32 3 ; [#uses=1] + %tmp136 = getelementptr %struct.QRectF* %tmp.upgrd.1, i32 0, i32 3 ; [#uses=1] + %tmp137 = load double* %tmp136 ; [#uses=1] + store double %tmp137, double* %tmp135 + %tmp138 = call double @_ZNK6QRectF6heightEv( %struct.QRectF* %body ) ; [#uses=1] + %tmp139 = sitofp i32 %tmp109.upgrd.17 to double ; [#uses=1] + %tmp140 = sub double %tmp138, %tmp139 ; [#uses=1] + %tmp142 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont141 unwind label %cleanup192 ; <%struct.QPaintDevice*> [#uses=1] +invcont141: ; preds = %invcont124 + invoke void @_ZNK13QTextDocument11defaultFontEv( %struct.QFont* sret %tmp.upgrd.3, %struct.QAbstractTextDocumentLayout* %tmp95 ) + to label %invcont144 unwind label %cleanup192 +invcont144: ; preds = %invcont141 + invoke void @_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice( %struct.QFontMetrics* %tmp.upgrd.2, %struct.QFont* %tmp.upgrd.3, %struct.QPaintDevice* %tmp142 ) + to label %invcont146 unwind label %cleanup173 +invcont146: ; preds = %invcont144 + %tmp149 = invoke i32 @_ZNK12QFontMetrics6ascentEv( %struct.QFontMetrics* %tmp.upgrd.2 ) + to label %invcont148 unwind label %cleanup168 ; [#uses=1] +invcont148: ; preds = %invcont146 + %tmp149.upgrd.21 = sitofp i32 %tmp149 to double ; [#uses=1] + %tmp150 = add double %tmp140, %tmp149.upgrd.21 ; [#uses=1] + %tmp152 = invoke %struct.QPaintDevice* @_ZNK8QPainter6deviceEv( %struct.QPainter* %p ) + to label %invcont151 unwind label %cleanup168 ; <%struct.QPaintDevice*> [#uses=1] +invcont151: ; preds = %invcont148 + %tmp154 = invoke i32 @_ZNK12QPaintDevice11logicalDpiYEv( %struct.QPaintDevice* %tmp152 ) + to label %invcont153 unwind label %cleanup168 ; [#uses=1] +invcont153: ; preds = %invcont151 + %tmp155 = mul i32 %tmp154, 5 ; [#uses=1] + %tmp156 = sdiv i32 %tmp155, 72 ; [#uses=1] + %tmp156.upgrd.22 = sitofp i32 %tmp156 to double ; [#uses=1] + %tmp157 = add double %tmp150, %tmp156.upgrd.22 ; [#uses=1] + %tmp158 = call double @_ZNK6QRectF5widthEv( %struct.QRectF* %body ) ; [#uses=1] + %tmp159 = sitofp i32 %tmp109.upgrd.17 to double ; [#uses=1] + %tmp160 = sub double %tmp158, %tmp159 ; [#uses=1] + call void @_ZN7QPointFC1Edd( %struct.QPointF* %tmp2, double %tmp160, double %tmp157 ) + %tmp161 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 0 ; [#uses=1] + %tmp162 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 0 ; [#uses=1] + %tmp163 = load double* %tmp162 ; [#uses=1] + store double %tmp163, double* %tmp161 + %tmp164 = getelementptr %struct.QPointF* %pageNumberPos, i32 0, i32 1 ; [#uses=1] + %tmp165 = getelementptr %struct.QPointF* %tmp2, i32 0, i32 1 ; [#uses=1] + %tmp166 = load double* %tmp165 ; [#uses=1] + store double %tmp166, double* %tmp164 + invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) + to label %cleanup171 unwind label %cleanup173 +cleanup168: ; preds = %invcont151, %invcont148, %invcont146 + invoke void @_ZN12QFontMetricsD1Ev( %struct.QFontMetrics* %tmp.upgrd.2 ) + to label %cleanup173 unwind label %cleanup173 +cleanup171: ; preds = %invcont153 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) + to label %finally170 unwind label %cleanup192 +cleanup173: ; preds = %cleanup168, %cleanup168, %invcont153, %invcont144 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %tmp.upgrd.3 ) + to label %cleanup192 unwind label %cleanup192 +finally170: ; preds = %cleanup171 + invoke void @_ZNK13QTextDocument11defaultFontEv( %struct.QFont* sret %font, %struct.QAbstractTextDocumentLayout* %tmp95 ) + to label %invcont177 unwind label %cleanup192 +invcont177: ; preds = %finally170 + invoke void @_ZN5QFont12setPointSizeEi( %struct.QFont* %font, i32 10 ) + to label %invcont179 unwind label %cleanup187 +invcont179: ; preds = %invcont177 + invoke void @_ZN13QTextDocument14setDefaultFontERK5QFont( %struct.QAbstractTextDocumentLayout* %tmp95, %struct.QFont* %font ) + to label %invcont181 unwind label %cleanup187 +invcont181: ; preds = %invcont179 + call void @_ZNK6QRectF4sizeEv( %struct.QPointF* sret %tmp3, %struct.QRectF* %body ) + invoke void @_ZN13QTextDocument11setPageSizeERK6QSizeF( %struct.QAbstractTextDocumentLayout* %tmp95, %struct.QPointF* %tmp3 ) + to label %cleanup185 unwind label %cleanup187 +cleanup185: ; preds = %invcont181 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) + to label %cleanup190 unwind label %cleanup192 +cleanup187: ; preds = %invcont181, %invcont179, %invcont177 + invoke void @_ZN5QFontD1Ev( %struct.QFont* %font ) + to label %cleanup192 unwind label %cleanup192 +cleanup190: ; preds = %cleanup185 + invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) + to label %cond_next194 unwind label %cleanup329 +cleanup192: ; preds = %cleanup187, %cleanup187, %cleanup185, %finally170, %cleanup173, %cleanup173, %cleanup171, %invcont141, %invcont124, %invcont122, %invcont120, %invcont118, %invcont117, %invcont114, %invcont111 + invoke void @_ZN16QTextFrameFormatD1Ev( %struct.QTextBlockFormat* %fmt ) + to label %cleanup329 unwind label %cleanup329 +cond_next194: ; preds = %cleanup190, %invcont83 + %clonedDoc.1 = phi %struct.QAbstractTextDocumentLayout* [ null, %invcont83 ], [ %tmp95, %cleanup190 ] ; <%struct.QAbstractTextDocumentLayout*> [#uses=3] + %doc.1 = phi %struct.QAbstractTextDocumentLayout* [ %this, %invcont83 ], [ %tmp95, %cleanup190 ] ; <%struct.QAbstractTextDocumentLayout*> [#uses=2] + %tmp197 = invoke i1 @_ZNK8QPrinter13collateCopiesEv( %struct.QPrinter* %printer ) + to label %invcont196 unwind label %cleanup329 ; [#uses=1] +invcont196: ; preds = %cond_next194 + br i1 %tmp197, label %cond_true200, label %cond_false204 +cond_true200: ; preds = %invcont196 + %tmp2000 = load double* %foo + store double %tmp2000, double* %bar + %tmp203 = invoke i32 @_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer ) + to label %cond_next208 unwind label %cleanup329 ; [#uses=1] +cond_false204: ; preds = %invcont196 + %tmp2001 = load double* %foo + store double %tmp2001, double* %bar + %tmp207 = invoke i32 @_ZNK8QPrinter9numCopiesEv( %struct.QPrinter* %printer ) + to label %cond_next208 unwind label %cleanup329 ; [#uses=1] +cond_next208: ; preds = %invcont206, %invcont202 + %pageCopies.0 = phi i32 [ %tmp203, %cond_true200 ], [ 1, %cond_false204 ] ; [#uses=2] + %docCopies.0 = phi i32 [ 1, %cond_true200 ], [ %tmp207, %cond_false204 ] ; [#uses=2] + %tmp211 = invoke i32 @_ZNK8QPrinter8fromPageEv( %struct.QPrinter* %printer ) + to label %invcont210 unwind label %cleanup329 ; [#uses=3] +invcont210: ; preds = %cond_next208 + %tmp214 = invoke i32 @_ZNK8QPrinter6toPageEv( %struct.QPrinter* %printer ) + to label %invcont213 unwind label %cleanup329 ; [#uses=3] +invcont213: ; preds = %invcont210 + %tmp216 = icmp eq i32 %tmp211, 0 ; [#uses=1] + br i1 %tmp216, label %cond_true217, label %cond_next225 +cond_true217: ; preds = %invcont213 + %tmp219 = icmp eq i32 %tmp214, 0 ; [#uses=1] + br i1 %tmp219, label %cond_true220, label %cond_next225 +cond_true220: ; preds = %cond_true217 + %tmp223 = invoke i32 @_ZNK13QTextDocument9pageCountEv( %struct.QAbstractTextDocumentLayout* %doc.1 ) + to label %invcont222 unwind label %cleanup329 ; [#uses=1] +invcont222: ; preds = %cond_true220 + br label %cond_next225 +cond_next225: ; preds = %invcont222, %cond_true217, %invcont213 + %toPage.1 = phi i32 [ %tmp223, %invcont222 ], [ %tmp214, %cond_true217 ], [ %tmp214, %invcont213 ] ; [#uses=2] + %fromPage.1 = phi i32 [ 1, %invcont222 ], [ %tmp211, %cond_true217 ], [ %tmp211, %invcont213 ] ; [#uses=2] + %tmp.page = invoke i32 @_ZNK8QPrinter9pageOrderEv( %struct.QPrinter* %printer ) + to label %invcont227 unwind label %cleanup329 ; [#uses=1] +invcont227: ; preds = %cond_next225 + %tmp228 = icmp eq i32 %tmp.page, 1 ; [#uses=1] + br i1 %tmp228, label %cond_true230, label %cond_next234 +cond_true230: ; preds = %invcont227 + br label %cond_next234 +cond_next234: ; preds = %cond_true230, %invcont227 + %ascending.1 = phi i1 [ false, %cond_true230 ], [ true, %invcont227 ] ; [#uses=1] + %toPage.2 = phi i32 [ %fromPage.1, %cond_true230 ], [ %toPage.1, %invcont227 ] ; [#uses=1] + %fromPage.2 = phi i32 [ %toPage.1, %cond_true230 ], [ %fromPage.1, %invcont227 ] ; [#uses=1] + br label %bb309 +bb237: ; preds = %cond_true313, %cond_next293 + %iftmp.410.4 = phi i1 [ %iftmp.410.5, %cond_true313 ], [ %iftmp.410.1, %cond_next293 ] ; [#uses=1] + %page.4 = phi i32 [ %fromPage.2, %cond_true313 ], [ %page.3, %cond_next293 ] ; [#uses=4] + br label %bb273 +invcont240: ; preds = %cond_true277 + %tmp242 = icmp eq i32 %tmp241, 2 ; [#uses=1] + br i1 %tmp242, label %bb252, label %cond_next244 +cond_next244: ; preds = %invcont240 + %tmp247 = invoke i32 @_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer ) + to label %invcont246 unwind label %cleanup329 ; [#uses=1] +invcont246: ; preds = %cond_next244 + %tmp248 = icmp eq i32 %tmp247, 3 ; [#uses=1] + br i1 %tmp248, label %bb252, label %bb253 +bb252: ; preds = %invcont246, %invcont240 + br label %bb254 +bb253: ; preds = %invcont246 + br label %bb254 +bb254: ; preds = %bb253, %bb252 + %iftmp.410.0 = phi i1 [ true, %bb252 ], [ false, %bb253 ] ; [#uses=2] + br i1 %iftmp.410.0, label %UserCanceled, label %cond_next258 +cond_next258: ; preds = %bb254 + invoke fastcc void @_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF( i32 %page.4, %struct.QPainter* %p, %struct.QAbstractTextDocumentLayout* %doc.1, %struct.QRectF* %body, %struct.QPointF* %pageNumberPos ) + to label %invcont261 unwind label %cleanup329 +invcont261: ; preds = %cond_next258 + %tmp263 = add i32 %pageCopies.0, -1 ; [#uses=1] + %tmp265 = icmp sgt i32 %tmp263, %j.4 ; [#uses=1] + br i1 %tmp265, label %cond_true266, label %cond_next270 +cond_true266: ; preds = %invcont261 + %tmp269 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) + to label %cond_next270 unwind label %cleanup329 ; [#uses=0] +cond_next270: ; preds = %cond_true266, %invcont261 + %tmp272 = add i32 %j.4, 1 ; [#uses=1] + br label %bb273 +bb273: ; preds = %cond_next270, %bb237 + %iftmp.410.1 = phi i1 [ %iftmp.410.4, %bb237 ], [ %iftmp.410.0, %cond_next270 ] ; [#uses=2] + %j.4 = phi i32 [ 0, %bb237 ], [ %tmp272, %cond_next270 ] ; [#uses=3] + %tmp276 = icmp slt i32 %j.4, %pageCopies.0 ; [#uses=1] + br i1 %tmp276, label %cond_true277, label %bb280 +cond_true277: ; preds = %bb273 + %tmp241 = invoke i32 @_ZNK8QPrinter12printerStateEv( %struct.QPrinter* %printer ) + to label %invcont240 unwind label %cleanup329 ; [#uses=1] +bb280: ; preds = %bb273 + %tmp283 = icmp eq i32 %page.4, %toPage.2 ; [#uses=1] + br i1 %tmp283, label %bb297, label %cond_next285 +cond_next285: ; preds = %bb280 + br i1 %ascending.1, label %cond_true287, label %cond_false290 +cond_true287: ; preds = %cond_next285 + %tmp289 = add i32 %page.4, 1 ; [#uses=1] + br label %cond_next293 +cond_false290: ; preds = %cond_next285 + %tmp292 = add i32 %page.4, -1 ; [#uses=1] + br label %cond_next293 +cond_next293: ; preds = %cond_false290, %cond_true287 + %page.3 = phi i32 [ %tmp289, %cond_true287 ], [ %tmp292, %cond_false290 ] ; [#uses=1] + %tmp296 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) + to label %bb237 unwind label %cleanup329 ; [#uses=0] +bb297: ; preds = %bb280 + %tmp299 = add i32 %docCopies.0, -1 ; [#uses=1] + %tmp301 = icmp sgt i32 %tmp299, %i.1 ; [#uses=1] + br i1 %tmp301, label %cond_true302, label %cond_next306 +cond_true302: ; preds = %bb297 + %tmp305 = invoke i1 @_ZN8QPrinter7newPageEv( %struct.QPrinter* %printer ) + to label %cond_next306 unwind label %cleanup329 ; [#uses=0] +cond_next306: ; preds = %cond_true302, %bb297 + %tmp308 = add i32 %i.1, 1 ; [#uses=1] + br label %bb309 +bb309: ; preds = %cond_next306, %cond_next234 + %iftmp.410.5 = phi i1 [ undef, %cond_next234 ], [ %iftmp.410.1, %cond_next306 ] ; [#uses=1] + %i.1 = phi i32 [ 0, %cond_next234 ], [ %tmp308, %cond_next306 ] ; [#uses=3] + %tmp312 = icmp slt i32 %i.1, %docCopies.0 ; [#uses=1] + br i1 %tmp312, label %cond_true313, label %UserCanceled +cond_true313: ; preds = %bb309 + br label %bb237 +UserCanceled: ; preds = %bb309, %bb254 + %tmp318 = icmp eq %struct.QAbstractTextDocumentLayout* %clonedDoc.1, null ; [#uses=1] + br i1 %tmp318, label %cleanup327, label %cond_true319 +cond_true319: ; preds = %UserCanceled + %tmp.upgrd.23 = getelementptr %struct.QAbstractTextDocumentLayout* %clonedDoc.1, i32 0, i32 0, i32 0 ; [#uses=1] + %tmp.upgrd.24 = load i32 (...)*** %tmp.upgrd.23 ; [#uses=1] + %tmp322 = getelementptr i32 (...)** %tmp.upgrd.24, i32 4 ; [#uses=1] + %tmp.upgrd.25 = load i32 (...)** %tmp322 ; [#uses=1] + %tmp.upgrd.26 = bitcast i32 (...)* %tmp.upgrd.25 to void (%struct.QAbstractTextDocumentLayout*)* ; [#uses=1] + invoke void %tmp.upgrd.26( %struct.QAbstractTextDocumentLayout* %clonedDoc.1 ) + to label %cleanup327 unwind label %cleanup329 +cleanup327: ; preds = %cond_true319, %UserCanceled + call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) + ret void +cleanup328: ; preds = %invcont + call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) + ret void +cleanup329: ; preds = %cond_true319, %cond_true302, %cond_next293, %cond_true277, %cond_true266, %cond_next258, %cond_next244, %cond_next225, %cond_true220, %invcont210, %cond_next208, %cond_false204, %cond_true200, %cond_next194, %cleanup192, %cleanup192, %cleanup190, %invcont106, %invcont104, %invcont103, %invcont100, %invcont98, %invcont94, %cond_false, %invcont83, %invcont79, %invcont57, %invcont51, %invcont45, %cond_next42, %invcont37, %cond_true35, %invcont29, %invcont25, %cond_true24, %cond_next, %entry + call void @_ZN8QPainterD1Ev( %struct.QPainter* %p ) + unwind +} + +declare void @_ZN6QSizeFC1Edd(%struct.QPointF*, double, double) + +declare i1 @_ZNK6QSizeF7isValidEv(%struct.QPointF*) + +declare double @_ZNK6QSizeF5widthEv(%struct.QPointF*) + +declare double @_ZNK6QSizeF6heightEv(%struct.QPointF*) + +declare double* @_ZN6QSizeF6rwidthEv(%struct.QPointF*) + +declare double* @_ZN6QSizeF7rheightEv(%struct.QPointF*) + +declare %struct.QTextDocumentPrivate* @_ZNK13QTextDocument6d_funcEv(%struct.QAbstractTextDocumentLayout*) + +declare void @_ZN7QPointFC1Ev(%struct.QPointF*) + +declare void @_ZN7QPointFC1Edd(%struct.QPointF*, double, double) + +declare void @_ZN16QTextFrameFormat9setMarginEd(%struct.QTextBlockFormat*, double) + +declare void @_ZN6QRectFC1Edddd(%struct.QRectF*, double, double, double, double) + +declare void @_ZN6QRectFC1ERK7QPointFRK6QSizeF(%struct.QRectF*, %struct.QPointF*, %struct.QPointF*) + +declare double @_ZNK6QRectF5widthEv(%struct.QRectF*) + +declare double @_ZNK6QRectF6heightEv(%struct.QRectF*) + +declare void @_ZNK6QRectF4sizeEv(%struct.QPointF*, %struct.QRectF*) + +declare void @_ZN16QTextFrameFormatD1Ev(%struct.QTextBlockFormat*) + +declare void @_ZNK10QTextFrame11frameFormatEv(%struct.QTextBlockFormat*, %struct.QTextBlockGroup*) + +declare void @_ZN10QTextFrame14setFrameFormatERK16QTextFrameFormat(%struct.QTextBlockGroup*, %struct.QTextBlockFormat*) + +declare i32 @_ZNK12QPaintDevice5widthEv(%struct.QPaintDevice*) + +declare i32 @_ZNK12QPaintDevice6heightEv(%struct.QPaintDevice*) + +declare i32 @_ZNK12QPaintDevice11logicalDpiXEv(%struct.QPaintDevice*) + +declare i32 @_ZNK12QPaintDevice11logicalDpiYEv(%struct.QPaintDevice*) + +declare %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument5cloneEP7QObject(%struct.QAbstractTextDocumentLayout*, %struct.QObject*) + +declare void @_ZN5QFontD1Ev(%struct.QFont*) + +declare %struct.QAbstractTextDocumentLayout* @_ZNK13QTextDocument14documentLayoutEv(%struct.QAbstractTextDocumentLayout*) + +declare %struct.QTextBlockGroup* @_ZNK13QTextDocument9rootFrameEv(%struct.QAbstractTextDocumentLayout*) + +declare i32 @_ZNK13QTextDocument9pageCountEv(%struct.QAbstractTextDocumentLayout*) + +declare void @_ZNK13QTextDocument11defaultFontEv(%struct.QFont*, %struct.QAbstractTextDocumentLayout*) + +declare void @_ZN13QTextDocument14setDefaultFontERK5QFont(%struct.QAbstractTextDocumentLayout*, %struct.QFont*) + +declare void @_ZN13QTextDocument11setPageSizeERK6QSizeF(%struct.QAbstractTextDocumentLayout*, %struct.QPointF*) + +declare void @_Z9printPageiP8QPainterPK13QTextDocumentRK6QRectFRK7QPointF(i32, %struct.QPainter*, %struct.QAbstractTextDocumentLayout*, %struct.QRectF*, %struct.QPointF*) + +declare void @_ZN12QFontMetricsD1Ev(%struct.QFontMetrics*) + +declare void @_ZN8QPainterC1EP12QPaintDevice(%struct.QPainter*, %struct.QPaintDevice*) + +declare i1 @_ZNK8QPainter8isActiveEv(%struct.QPainter*) + +declare i32 @_Z13qt_defaultDpiv() + +declare %struct.QPaintDevice* @_ZNK27QAbstractTextDocumentLayout11paintDeviceEv(%struct.QAbstractTextDocumentLayout*) + +declare void @_ZN8QPainter5scaleEdd(%struct.QPainter*, double, double) + +declare %struct.QPaintDevice* @_ZNK8QPainter6deviceEv(%struct.QPainter*) + +declare void @_ZN27QAbstractTextDocumentLayout14setPaintDeviceEP12QPaintDevice(%struct.QAbstractTextDocumentLayout*, %struct.QPaintDevice*) + +declare void @_ZN12QFontMetricsC1ERK5QFontP12QPaintDevice(%struct.QFontMetrics*, %struct.QFont*, %struct.QPaintDevice*) + +declare i32 @_ZNK12QFontMetrics6ascentEv(%struct.QFontMetrics*) + +declare void @_ZN5QFont12setPointSizeEi(%struct.QFont*, i32) + +declare i1 @_ZNK8QPrinter13collateCopiesEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter9numCopiesEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter8fromPageEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter6toPageEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter9pageOrderEv(%struct.QPrinter*) + +declare i32 @_ZNK8QPrinter12printerStateEv(%struct.QPrinter*) + +declare i1 @_ZN8QPrinter7newPageEv(%struct.QPrinter*) + +declare void @_ZN8QPainterD1Ev(%struct.QPainter*) From isanbard at gmail.com Mon Jun 15 15:59:31 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 15 Jun 2009 20:59:31 -0000 Subject: [llvm-commits] [llvm] r73417 - in /llvm/trunk/lib/Target/X86: X86Instr64bit.td X86InstrInfo.td Message-ID: <200906152059.n5FKxXmY007991@zion.cs.uiuc.edu> Author: void Date: Mon Jun 15 15:59:31 2009 New Revision: 73417 URL: http://llvm.org/viewvc/llvm-project?rev=73417&view=rev Log: The Ls and Qs were mixed up. Patch by Sean. Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=73417&r1=73416&r2=73417&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Jun 15 15:59:31 2009 @@ -179,11 +179,11 @@ let Defs = [RSP], Uses = [RSP], neverHasSideEffects = 1, mayStore = 1 in { def PUSH64i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm), - "push{l}\t$imm", []>; + "push{q}\t$imm", []>; def PUSH64i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm), - "push{l}\t$imm", []>; + "push{q}\t$imm", []>; def PUSH64i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm), - "push{l}\t$imm", []>; + "push{q}\t$imm", []>; } let Defs = [RSP, EFLAGS], Uses = [RSP], mayLoad = 1 in Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=73417&r1=73416&r2=73417&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jun 15 15:59:31 2009 @@ -613,11 +613,11 @@ let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in { def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm), - "push{q}\t$imm", []>; + "push{l}\t$imm", []>; def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm), - "push{q}\t$imm", []>; + "push{l}\t$imm", []>; def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm), - "push{q}\t$imm", []>; + "push{l}\t$imm", []>; } let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in From kremenek at apple.com Mon Jun 15 16:06:29 2009 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 15 Jun 2009 21:06:29 -0000 Subject: [llvm-commits] [llvm] r73418 - /llvm/tags/checker/checker-0.211/ Message-ID: <200906152106.n5FL6TpP008248@zion.cs.uiuc.edu> Author: kremenek Date: Mon Jun 15 16:06:28 2009 New Revision: 73418 URL: http://llvm.org/viewvc/llvm-project?rev=73418&view=rev Log: Tagging checker-0.211. Added: llvm/tags/checker/checker-0.211/ - copied from r73417, llvm/trunk/ From gohman at apple.com Mon Jun 15 16:18:02 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 21:18:02 -0000 Subject: [llvm-commits] [llvm] r73421 - /llvm/trunk/docs/LangRef.html Message-ID: <200906152118.n5FLI25H008675@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 16:18:01 2009 New Revision: 73421 URL: http://llvm.org/viewvc/llvm-project?rev=73421&view=rev Log: Rewrite the noredzone description, attempting to avoid confusing language. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=73421&r1=73420&r2=73421&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Jun 15 16:18:01 2009 @@ -1107,7 +1107,7 @@
    noredzone
    This attribute indicates that the code generator should not use a -red zone, even if it would otherwise be supported by the target-specific ABI. +red zone, even if the target-specific ABI normally permits it.
    noimplicitfloat
    From evan.cheng at apple.com Mon Jun 15 16:18:20 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 15 Jun 2009 21:18:20 -0000 Subject: [llvm-commits] [llvm] r73422 - /llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Message-ID: <200906152118.n5FLILLN008694@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jun 15 16:18:20 2009 New Revision: 73422 URL: http://llvm.org/viewvc/llvm-project?rev=73422&view=rev Log: Typo. Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=73422&r1=73421&r2=73422&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Mon Jun 15 16:18:20 2009 @@ -1040,7 +1040,7 @@ Offset = ARM_AM::getAM3Opc(AddSub, OffImm); EvenReg = Op0->getOperand(0).getReg(); - OddReg = Op0->getOperand(1).getReg(); + OddReg = Op1->getOperand(0).getReg(); if (EvenReg == OddReg) return false; BaseReg = Op0->getOperand(1).getReg(); From gohman at apple.com Mon Jun 15 16:19:14 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 14:19:14 -0700 Subject: [llvm-commits] [llvm] r73394 - /llvm/trunk/docs/LangRef.html In-Reply-To: <4A36A1A2.8050400@free.fr> References: <200906151737.n5FHbA71032426@zion.cs.uiuc.edu> <4A36A1A2.8050400@free.fr> Message-ID: <3E49F266-815C-4A38-84EC-CE29EFA24292@apple.com> On Jun 15, 2009, at 12:31 PM, Duncan Sands wrote: > Hi Dan, > > >> -
    This attribute indicates that the code generator should not >> enforce red zone >> >> -mandated by target specific ABI.
    >> >> +
    This attribute indicates that the code generator should not >> use a >> >> +red zone, even if it would otherwise be supported by the target- >> specific ABI. >> >> +
    >> > > I personally found the original clearer. I'm not sure what it means > for > an ABI to support something; and the phrase seems to contain several > negations ("should not", "would otherwise") which left me confused. I just committed a new version; hopefully it's more clear. Dan From deeppatel1987 at gmail.com Mon Jun 15 16:22:22 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Mon, 15 Jun 2009 14:22:22 -0700 Subject: [llvm-commits] [llvm] r73095 - in /llvm/trunk: include/llvm/Target/TargetMachine.h include/llvm/Target/TargetOptions.h lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMRegist In-Reply-To: <305d6f60906110010l37762b0br64c9d75b7f149915@mail.gmail.com> References: <305d6f60906110010l37762b0br64c9d75b7f149915@mail.gmail.com> Message-ID: <305d6f60906151422x6d609255r70cfce048a421249@mail.gmail.com> On Thu, Jun 11, 2009 at 12:10 AM, Sandeep Patel wrote: > On Wed, Jun 10, 2009 at 9:43 PM, Evan Cheng wrote: >> >> On Jun 8, 2009, at 3:53 PM, Anton Korobeynikov wrote: >> >>> Author: asl >>> Date: Mon Jun ?8 17:53:56 2009 >>> New Revision: 73095 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=73095&view=rev >>> Log: >>> The attached patches implement most of the ARM AAPCS-VFP hard float >>> ABI. The missing piece is support for putting "homogeneous aggregates" >>> into registers. >>> >>> Patch by Sandeep Patel! >>> >>> Modified: >>> ? ?llvm/trunk/include/llvm/Target/TargetMachine.h >>> ? ?llvm/trunk/include/llvm/Target/TargetOptions.h >>> ? ?llvm/trunk/lib/Target/ARM/ARMCallingConv.td >>> ? ?llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp >>> ? ?llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp >>> ? ?llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td >>> ? ?llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp >>> ? ?llvm/trunk/lib/Target/TargetMachine.cpp >>> ? ?llvm/trunk/lib/Target/X86/X86Subtarget.cpp >>> >>> Modified: llvm/trunk/include/llvm/Target/TargetMachine.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=73095&r1=73094&r2=73095&view=diff >>> >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ====================================================================== >>> --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) >>> +++ llvm/trunk/include/llvm/Target/TargetMachine.h Mon Jun ?8 >>> 17:53:56 2009 >>> @@ -78,6 +78,14 @@ >>> ? }; >>> } >> >>> >>> >>> +namespace FloatABI { >>> + ?enum ABIType { >>> + ? ?Default, >>> + ? ?Soft, >>> + ? ?Hard >>> + ?}; >>> +} >> >> Some comments? > > Will do. Comments added in attached patch. deep -------------- next part -------------- A non-text attachment was scrubbed... Name: llvmdiffs.patch Type: application/octet-stream Size: 453 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090615/a17122d5/attachment.obj From evan.cheng at apple.com Mon Jun 15 16:24:34 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 15 Jun 2009 21:24:34 -0000 Subject: [llvm-commits] [llvm] r73423 - in /llvm/trunk: lib/CodeGen/IfConversion.cpp test/CodeGen/ARM/ifcvt9.ll Message-ID: <200906152124.n5FLOYor008921@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jun 15 16:24:34 2009 New Revision: 73423 URL: http://llvm.org/viewvc/llvm-project?rev=73423&view=rev Log: ifcvt should ignore cfg where true and false successors are the same. Added: llvm/trunk/test/CodeGen/ARM/ifcvt9.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=73423&r1=73422&r2=73423&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Mon Jun 15 16:24:34 2009 @@ -547,7 +547,11 @@ // fallthrough. if (!BBI.FalseBB) BBI.FalseBB = findFalseBlock(BBI.BB, BBI.TrueBB); - assert(BBI.FalseBB && "Expected to find the fallthrough block!"); + if (!BBI.FalseBB) { + // Malformed bcc? True and false blocks are the same? + BBI.IsUnpredicable = true; + return; + } } // Then scan all the instructions. @@ -663,6 +667,13 @@ return BBI; } + // Do not ifcvt if true and false fallthrough blocks are the same. + if (!BBI.FalseBB) { + BBI.IsBeingAnalyzed = false; + BBI.IsAnalyzed = true; + return BBI; + } + BBInfo &TrueBBI = AnalyzeBlock(BBI.TrueBB, Tokens); BBInfo &FalseBBI = AnalyzeBlock(BBI.FalseBB, Tokens); Added: llvm/trunk/test/CodeGen/ARM/ifcvt9.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/ifcvt9.ll?rev=73423&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/ifcvt9.ll (added) +++ llvm/trunk/test/CodeGen/ARM/ifcvt9.ll Mon Jun 15 16:24:34 2009 @@ -0,0 +1,12 @@ +; RUN: llvm-as < %s | llc -march=arm + +define fastcc void @t() nounwind { +entry: + br i1 undef, label %bb.i.i3, label %growMapping.exit + +bb.i.i3: ; preds = %entry + unreachable + +growMapping.exit: ; preds = %entry + unreachable +} From dpatel at apple.com Mon Jun 15 16:45:51 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 15 Jun 2009 21:45:51 -0000 Subject: [llvm-commits] [llvm] r73426 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/SelectionDAG/FastISel.cpp test/DebugInfo/2009-06-15-InlineFuncStart.ll Message-ID: <200906152145.n5FLjpHw009714@zion.cs.uiuc.edu> Author: dpatel Date: Mon Jun 15 16:45:50 2009 New Revision: 73426 URL: http://llvm.org/viewvc/llvm-project?rev=73426&view=rev Log: Gracefully handle imbalanced inline function begin and end markers. Added: llvm/trunk/test/DebugInfo/2009-06-15-InlineFuncStart.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=73426&r1=73425&r2=73426&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Jun 15 16:45:50 2009 @@ -1850,7 +1850,14 @@ } SmallVector &Scopes = I->second; - assert(!Scopes.empty() && "We should have at least one debug scope!"); + if (Scopes.empty()) { + // Returned ID is 0 if this is unbalanced "end of inlined + // scope". This could happen if optimizer eats dbg intrinsics + // or "beginning of inlined scope" is not recoginized due to + // missing location info. In such cases, ignore this region.end. + return 0; + } + DbgScope *Scope = Scopes.back(); Scopes.pop_back(); unsigned ID = MMI->NextLabelID(); MMI->RecordUsedDbgLabel(ID); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=73426&r1=73425&r2=73426&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Mon Jun 15 16:45:50 2009 @@ -361,7 +361,7 @@ // Returned ID is 0 if this is unbalanced "end of inlined // scope". This could happen if optimizer eats dbg intrinsics // or "beginning of inlined scope" is not recoginized due to - // missing location info. In such cases, do ignore this region.end. + // missing location info. In such cases, ignore this region.end. BuildMI(MBB, DL, II).addImm(ID); } else { const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL); Added: llvm/trunk/test/DebugInfo/2009-06-15-InlineFuncStart.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-06-15-InlineFuncStart.ll?rev=73426&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-06-15-InlineFuncStart.ll (added) +++ llvm/trunk/test/DebugInfo/2009-06-15-InlineFuncStart.ll Mon Jun 15 16:45:50 2009 @@ -0,0 +1,77 @@ +; Test inlined function handling. This test case is copied from +; 2009-06-12-InlineFunctStart.ll with one change. In function main, the bb1 +; does not have llvm.dbg.stoppiont intrinsic before llvm.dbg.func.start. +; RUN: llvm-as < %s | llc +; RUN: llvm-as < %s | llc -O0 + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.basictype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8* } + %llvm.dbg.subprogram.type = type { i32, { }*, { }*, i8*, i8*, i8*, { }*, i32, { }*, i1, i1 } + at llvm.dbg.subprogram = internal constant %llvm.dbg.subprogram.type { i32 393262, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str3, i32 0, i32 0), i8* getelementptr ([4 x i8]* @.str3, i32 0, i32 0), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 1, { }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at llvm.dbg.subprograms = linkonce constant %llvm.dbg.anchor.type { i32 393216, i32 46 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] + at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 393233, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([5 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([52 x i8]* @.str2, i32 0, i32 0) }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] + at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 393216, i32 17 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] + at .str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] + at .str1 = internal constant [5 x i8] c"/tmp\00", section "llvm.metadata" ; <[5 x i8]*> [#uses=1] + at .str2 = internal constant [52 x i8] c"4.2.1 (Based on Apple Inc. build 5627) (LLVM build)\00", section "llvm.metadata" ; <[52 x i8]*> [#uses=1] + at .str3 = internal constant [4 x i8] c"foo\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] + at llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type { i32 393252, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str4, i32 0, i32 0), { }* null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5 }, section "llvm.metadata" ; <%llvm.dbg.basictype.type*> [#uses=1] + at .str4 = internal constant [4 x i8] c"int\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] + at llvm.dbg.subprogram5 = internal constant %llvm.dbg.subprogram.type { i32 393262, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([5 x i8]* @.str6, i32 0, i32 0), i8* getelementptr ([5 x i8]* @.str6, i32 0, i32 0), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 2, { }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at .str6 = internal constant [5 x i8] c"main\00", section "llvm.metadata" ; <[5 x i8]*> [#uses=1] + +define i32 @foo() nounwind alwaysinline { +entry: + %retval = alloca i32 ; [#uses=2] + %0 = alloca i32 ; [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*)) + call void @llvm.dbg.stoppoint(i32 1, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + store i32 42, i32* %0, align 4 + %1 = load i32* %0, align 4 ; [#uses=1] + store i32 %1, i32* %retval, align 4 + br label %return + +return: ; preds = %entry + %retval1 = load i32* %retval ; [#uses=1] + call void @llvm.dbg.stoppoint(i32 1, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*)) + ret i32 %retval1 +} + +declare void @llvm.dbg.func.start({ }*) nounwind + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind + +declare void @llvm.dbg.region.end({ }*) nounwind + +define i32 @main() nounwind { +entry: + %retval.i = alloca i32 ; [#uses=2] + %0 = alloca i32 ; [#uses=2] + %retval = alloca i32 ; [#uses=2] + %1 = alloca i32 ; [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram5 to { }*)) + br label %bb1 + +return: ; preds = %entry + %retval1 = load i32* %retval ; [#uses=1] + call void @llvm.dbg.stoppoint(i32 2, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram5 to { }*)) + ret i32 %retval1 + +bb1: + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*)) nounwind + call void @llvm.dbg.stoppoint(i32 1, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) nounwind + store i32 42, i32* %0, align 4 + %2 = load i32* %0, align 4 ; [#uses=1] + store i32 %2, i32* %retval.i, align 4 + %retval1.i = load i32* %retval.i ; [#uses=1] + call void @llvm.dbg.stoppoint(i32 1, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) nounwind + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*)) nounwind + store i32 %retval1.i, i32* %1, align 4 + %3 = load i32* %1, align 4 ; [#uses=1] + store i32 %3, i32* %retval, align 4 + br label %return +} From asl at math.spbu.ru Mon Jun 15 16:46:02 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 15 Jun 2009 21:46:02 -0000 Subject: [llvm-commits] [llvm] r73427 - /llvm/trunk/include/llvm/Target/TargetMachine.h Message-ID: <200906152146.n5FLk2Jx009730@zion.cs.uiuc.edu> Author: asl Date: Mon Jun 15 16:46:02 2009 New Revision: 73427 URL: http://llvm.org/viewvc/llvm-project?rev=73427&view=rev Log: Document ABIType enum. Patch by Sandeep Patel! Modified: llvm/trunk/include/llvm/Target/TargetMachine.h Modified: llvm/trunk/include/llvm/Target/TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=73427&r1=73426&r2=73427&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) +++ llvm/trunk/include/llvm/Target/TargetMachine.h Mon Jun 15 16:46:02 2009 @@ -78,6 +78,9 @@ }; } + +// Possible float ABI settings. Soft is soft float, Hard is hard float, Default +// is target-specific. Used with FloatABIType in TargetOptions.h. namespace FloatABI { enum ABIType { Default, From asl at math.spbu.ru Mon Jun 15 16:46:20 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 15 Jun 2009 21:46:20 -0000 Subject: [llvm-commits] [llvm] r73428 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMSubtarget.h Message-ID: <200906152146.n5FLkKKQ009748@zion.cs.uiuc.edu> Author: asl Date: Mon Jun 15 16:46:20 2009 New Revision: 73428 URL: http://llvm.org/viewvc/llvm-project?rev=73428&view=rev Log: Rename methods for the sake of consistency. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMSubtarget.h Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=73428&r1=73427&r2=73428&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Mon Jun 15 16:46:20 2009 @@ -90,12 +90,12 @@ //===----------------------------------------------------------------------===// // ARM Instruction Predicate Definitions. // -def HasV5T : Predicate<"Subtarget->hasV5TOps()">; -def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">; -def HasV6 : Predicate<"Subtarget->hasV6Ops()">; -def IsThumb : Predicate<"Subtarget->isThumb()">; -def IsThumb2 : Predicate<"Subtarget->isThumb2()">; -def IsARM : Predicate<"!Subtarget->isThumb()">; +def HasV5T : Predicate<"Subtarget->hasV5TOps()">; +def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">; +def HasV6 : Predicate<"Subtarget->hasV6Ops()">; +def IsThumb : Predicate<"Subtarget->isThumb()">; +def HasThumb2 : Predicate<"Subtarget->hasThumb2()">; +def IsARM : Predicate<"!Subtarget->isThumb()">; //===----------------------------------------------------------------------===// // ARM Flag Definitions. Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=73428&r1=73427&r2=73428&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Mon Jun 15 16:46:20 2009 @@ -106,8 +106,8 @@ bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; } bool isThumb() const { return IsThumb; } - bool isThumb1() const { return IsThumb && (ThumbMode == Thumb1); } - bool isThumb2() const { return IsThumb && (ThumbMode >= Thumb2); } + bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); } + bool hasThumb2() const { return IsThumb && (ThumbMode >= Thumb2); } bool useThumbBacktraces() const { return UseThumbBacktraces; } bool isR9Reserved() const { return IsR9Reserved; } From gohman at apple.com Mon Jun 15 16:52:11 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 21:52:11 -0000 Subject: [llvm-commits] [llvm] r73429 - /llvm/trunk/lib/AsmParser/LLParser.cpp Message-ID: <200906152152.n5FLqB5F009977@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 16:52:11 2009 New Revision: 73429 URL: http://llvm.org/viewvc/llvm-project?rev=73429&view=rev Log: Fix a typo in a diagnostic. Modified: llvm/trunk/lib/AsmParser/LLParser.cpp Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=73429&r1=73428&r2=73429&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jun 15 16:52:11 2009 @@ -1743,7 +1743,7 @@ Lex.Lex(); if (ParseToken(lltok::lparen, "expected '(' after constantexpr cast") || ParseGlobalTypeAndValue(SrcVal) || - ParseToken(lltok::kw_to, "expected 'to' int constantexpr cast") || + ParseToken(lltok::kw_to, "expected 'to' in constantexpr cast") || ParseType(DestTy) || ParseToken(lltok::rparen, "expected ')' at end of constantexpr cast")) return true; From isanbard at gmail.com Mon Jun 15 17:04:18 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 15 Jun 2009 15:04:18 -0700 Subject: [llvm-commits] [llvm] r73095 - in /llvm/trunk: include/llvm/Target/TargetMachine.h include/llvm/Target/TargetOptions.h lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMRegist In-Reply-To: <305d6f60906151422x6d609255r70cfce048a421249@mail.gmail.com> References: <305d6f60906110010l37762b0br64c9d75b7f149915@mail.gmail.com> <305d6f60906151422x6d609255r70cfce048a421249@mail.gmail.com> Message-ID: <16e5fdf90906151504m79c8b74dqe06c74b313cee150@mail.gmail.com> On Mon, Jun 15, 2009 at 2:22 PM, Sandeep Patel wrote: >>>> >>>> +namespace FloatABI { >>>> + ?enum ABIType { >>>> + ? ?Default, >>>> + ? ?Soft, >>>> + ? ?Hard >>>> + ?}; >>>> +} >>> >>> Some comments? >> >> Will do. > > Comments added in attached patch. > Thanks! One nitpick (take with as many grains of salt as you wish. :-) ) You can put short comments for individual values of an enum inline with the enum value. I.e.: namespace FloatABI { enum ABIType { Default, // Target-specific Hard, // Hard float etc. -bw From anton at korobeynikov.info Mon Jun 15 17:03:38 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 16 Jun 2009 02:03:38 +0400 Subject: [llvm-commits] [llvm] r73095 - in /llvm/trunk: include/llvm/Target/TargetMachine.h include/llvm/Target/TargetOptions.h lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMRegist In-Reply-To: <16e5fdf90906151504m79c8b74dqe06c74b313cee150@mail.gmail.com> References: <305d6f60906110010l37762b0br64c9d75b7f149915@mail.gmail.com> <305d6f60906151422x6d609255r70cfce048a421249@mail.gmail.com> <16e5fdf90906151504m79c8b74dqe06c74b313cee150@mail.gmail.com> Message-ID: <1245103418.30739.0.camel@aslstation> Hi, Bill > Thanks! One nitpick (take with as many grains of salt as you wish. :-) > ) You can put short comments for individual values of an enum inline > with the enum value. I.e.: However stuff around does not have such comments. Anyway, I will add them :) -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University. From isanbard at gmail.com Mon Jun 15 17:07:52 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 15 Jun 2009 15:07:52 -0700 Subject: [llvm-commits] [llvm] r73095 - in /llvm/trunk: include/llvm/Target/TargetMachine.h include/llvm/Target/TargetOptions.h lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMRegist In-Reply-To: <1245103418.30739.0.camel@aslstation> References: <305d6f60906110010l37762b0br64c9d75b7f149915@mail.gmail.com> <305d6f60906151422x6d609255r70cfce048a421249@mail.gmail.com> <16e5fdf90906151504m79c8b74dqe06c74b313cee150@mail.gmail.com> <1245103418.30739.0.camel@aslstation> Message-ID: <16e5fdf90906151507w3287da3ag1e78eb3de003c1a2@mail.gmail.com> On Mon, Jun 15, 2009 at 3:03 PM, Anton Korobeynikov wrote: > Hi, Bill > >> Thanks! One nitpick (take with as many grains of salt as you wish. :-) >> ) You can put short comments for individual values of an enum inline >> with the enum value. I.e.: > However stuff around does not have such comments. Anyway, I will add > them :) > Quite true! :-) But thanks. -bw From asl at math.spbu.ru Mon Jun 15 17:08:48 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 15 Jun 2009 22:08:48 -0000 Subject: [llvm-commits] [llvm] r73430 - /llvm/trunk/include/llvm/Target/TargetMachine.h Message-ID: <200906152208.n5FM8m5F010448@zion.cs.uiuc.edu> Author: asl Date: Mon Jun 15 17:08:48 2009 New Revision: 73430 URL: http://llvm.org/viewvc/llvm-project?rev=73430&view=rev Log: Address more comments :) Modified: llvm/trunk/include/llvm/Target/TargetMachine.h Modified: llvm/trunk/include/llvm/Target/TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=73430&r1=73429&r2=73430&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) +++ llvm/trunk/include/llvm/Target/TargetMachine.h Mon Jun 15 17:08:48 2009 @@ -79,13 +79,12 @@ } -// Possible float ABI settings. Soft is soft float, Hard is hard float, Default -// is target-specific. Used with FloatABIType in TargetOptions.h. +// Possible float ABI settings. Used with FloatABIType in TargetOptions.h. namespace FloatABI { enum ABIType { - Default, - Soft, - Hard + Default, // Target-specific (either soft of hard depending on triple, etc). + Soft, // Soft float. + Hard // Hard float. }; } From gohman at apple.com Mon Jun 15 17:12:55 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 22:12:55 -0000 Subject: [llvm-commits] [llvm] r73431 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ lib/Analysis/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/VMCore/ test/Feature/ test/Transforms/InstCombine/ Message-ID: <200906152212.n5FMCuvr010609@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 17:12:54 2009 New Revision: 73431 URL: http://llvm.org/viewvc/llvm-project?rev=73431&view=rev Log: Support vector casts in more places, fixing a variety of assertion failures. To support this, add some utility functions to Type to help support vector/scalar-independent code. Change ConstantInt::get and ConstantFP::get to support vector types, and add an overload to ConstantInt::get that uses a static IntegerType type, for convenience. Introduce a new getConstant method for ScalarEvolution, to simplify common use cases. Added: llvm/trunk/test/Feature/vector-cast-constant-exprs.ll llvm/trunk/test/Transforms/InstCombine/vector-casts.ll Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/include/llvm/Constants.h llvm/trunk/include/llvm/Type.h llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp llvm/trunk/lib/Analysis/ValueTracking.cpp llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon Jun 15 17:12:54 2009 @@ -418,6 +418,7 @@ SCEVHandle getConstant(ConstantInt *V); SCEVHandle getConstant(const APInt& Val); + SCEVHandle getConstant(const Type *Ty, uint64_t V, bool isSigned = false); SCEVHandle getTruncateExpr(const SCEVHandle &Op, const Type *Ty); SCEVHandle getZeroExtendExpr(const SCEVHandle &Op, const Type *Ty); SCEVHandle getSignExtendExpr(const SCEVHandle &Op, const Type *Ty); Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Mon Jun 15 17:12:54 2009 @@ -107,14 +107,19 @@ /// either getSExtValue() or getZExtValue() will yield a correctly sized and /// signed value for the type Ty. /// @brief Get a ConstantInt for a specific value. - static ConstantInt *get(const Type *Ty, uint64_t V, bool isSigned = false); + static ConstantInt *get(const IntegerType *Ty, + uint64_t V, bool isSigned = false); + static Constant *get(const Type *Ty, uint64_t V, bool isSigned = false); /// Return a ConstantInt with the specified value for the specified type. The /// value V will be canonicalized to a an unsigned APInt. Accessing it with /// either getSExtValue() or getZExtValue() will yield a correctly sized and /// signed value for the type Ty. /// @brief Get a ConstantInt for a specific signed value. - static ConstantInt *getSigned(const Type *Ty, int64_t V) { + static ConstantInt *getSigned(const IntegerType *Ty, int64_t V) { + return get(Ty, V, true); + } + static Constant *getSigned(const Type *Ty, int64_t V) { return get(Ty, V, true); } @@ -122,6 +127,10 @@ /// type is the integer type that corresponds to the bit width of the value. static ConstantInt *get(const APInt &V); + /// If Ty is a vector type, return a Constant with a splat of the given + /// value. Otherwise return a ConstantInt for the given value. + static Constant *get(const Type *Ty, const APInt &V); + /// getType - Specialize the getType() method to always return an IntegerType, /// which reduces the amount of casting needed in parts of the compiler. /// @@ -251,7 +260,7 @@ /// get() - This returns a constant fp for the specified value in the /// specified type. This should only be used for simple constant values like /// 2.0/1.0 etc, that are known-valid both as double and as the target format. - static ConstantFP *get(const Type *Ty, double V); + static Constant *get(const Type *Ty, double V); /// isValueValidForType - return true if Ty is big enough to represent V. static bool isValueValidForType(const Type *Ty, const APFloat& V); Modified: llvm/trunk/include/llvm/Type.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Type.h?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/include/llvm/Type.h (original) +++ llvm/trunk/include/llvm/Type.h Mon Jun 15 17:12:54 2009 @@ -268,19 +268,16 @@ /// primitive type. /// unsigned getPrimitiveSizeInBits() const; - + + /// getScalarSizeInBits - If this is a vector type, return the + /// getPrimitiveSizeInBits value for the element type. Otherwise return the + /// getPrimitiveSizeInBits value for this type. + unsigned getScalarSizeInBits() const; + /// getFPMantissaWidth - Return the width of the mantissa of this type. This - /// is only valid on scalar floating point types. If the FP type does not + /// is only valid on floating point types. If the FP type does not /// have a stable mantissa (e.g. ppc long double), this method returns -1. - int getFPMantissaWidth() const { - assert(isFloatingPoint() && "Not a floating point type!"); - if (ID == FloatTyID) return 24; - if (ID == DoubleTyID) return 53; - if (ID == X86_FP80TyID) return 64; - if (ID == FP128TyID) return 113; - assert(ID == PPC_FP128TyID && "unknown fp type"); - return -1; - } + int getFPMantissaWidth() const; /// getForwardedType - Return the type that this type has been resolved to if /// it has been resolved to anything. This is used to implement the @@ -296,6 +293,10 @@ /// function. const Type *getVAArgsPromotedType() const; + /// getScalarType - If this is a vector type, return the element type, + /// otherwise return this. + const Type *getScalarType() const; + //===--------------------------------------------------------------------===// // Type Iteration support // Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Mon Jun 15 17:12:54 2009 @@ -365,7 +365,7 @@ if (ConstantExpr *CE = dyn_cast(Ops[0])) { if (TD && CE->getOpcode() == Instruction::IntToPtr) { Constant *Input = CE->getOperand(0); - unsigned InWidth = Input->getType()->getPrimitiveSizeInBits(); + unsigned InWidth = Input->getType()->getScalarSizeInBits(); if (TD->getPointerSizeInBits() < InWidth) { Constant *Mask = ConstantInt::get(APInt::getLowBitsSet(InWidth, @@ -384,7 +384,7 @@ if (ConstantExpr *CE = dyn_cast(Ops[0])) { if (TD && TD->getPointerSizeInBits() <= - CE->getType()->getPrimitiveSizeInBits()) { + CE->getType()->getScalarSizeInBits()) { if (CE->getOpcode() == Instruction::PtrToInt) { Constant *Input = CE->getOperand(0); Constant *C = FoldBitCast(Input, DestTy, *TD); Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jun 15 17:12:54 2009 @@ -186,6 +186,11 @@ return getConstant(ConstantInt::get(Val)); } +SCEVHandle +ScalarEvolution::getConstant(const Type *Ty, uint64_t V, bool isSigned) { + return getConstant(ConstantInt::get(cast(Ty), V, isSigned)); +} + const Type *SCEVConstant::getType() const { return V->getType(); } void SCEVConstant::print(raw_ostream &OS) const { @@ -2891,7 +2896,7 @@ unsigned MaxSteps = MaxBruteForceIterations; for (unsigned IterationNum = 0; IterationNum != MaxSteps; ++IterationNum) { ConstantInt *ItCst = - ConstantInt::get(IdxExpr->getType(), IterationNum); + ConstantInt::get(cast(IdxExpr->getType()), IterationNum); ConstantInt *Val = EvaluateConstantChrecAtConstant(IdxExpr, ItCst, *this); // Form the GEP offset. @@ -3086,7 +3091,7 @@ if (CondVal->getValue() == uint64_t(ExitWhen)) { ConstantEvolutionLoopExitValue[PN] = PHIVal; ++NumBruteForceTripCountsComputed; - return getConstant(ConstantInt::get(Type::Int32Ty, IterationNum)); + return getConstant(Type::Int32Ty, IterationNum); } // Compute the value of the PHI node for the next iteration. @@ -3777,7 +3782,7 @@ // iteration exits. unsigned BitWidth = SE.getTypeSizeInBits(getType()); if (!Range.contains(APInt(BitWidth, 0))) - return SE.getConstant(ConstantInt::get(getType(),0)); + return SE.getIntegerSCEV(0, getType()); if (isAffine()) { // If this is an affine expression then we have this situation: Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Jun 15 17:12:54 2009 @@ -298,9 +298,7 @@ GepIndices.push_back(ConstantInt::get(Type::Int32Ty, ElIdx)); ElTy = STy->getTypeAtIndex(ElIdx); Ops[0] = - SE.getConstant(ConstantInt::get(Ty, - FullOffset - - SL.getElementOffset(ElIdx))); + SE.getConstant(Ty, FullOffset - SL.getElementOffset(ElIdx)); AnyNonZeroIndices = true; continue; } Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Jun 15 17:12:54 2009 @@ -52,11 +52,12 @@ assert(V && "No Value?"); assert(Depth <= MaxDepth && "Limit Search Depth"); unsigned BitWidth = Mask.getBitWidth(); - assert((V->getType()->isInteger() || isa(V->getType())) && + assert((V->getType()->isIntOrIntVector() || isa(V->getType())) && "Not integer or pointer type!"); - assert((!TD || TD->getTypeSizeInBits(V->getType()) == BitWidth) && - (!isa(V->getType()) || - V->getType()->getPrimitiveSizeInBits() == BitWidth) && + assert((!TD || + TD->getTypeSizeInBits(V->getType()->getScalarType()) == BitWidth) && + (!V->getType()->isIntOrIntVector() || + V->getType()->getScalarSizeInBits() == BitWidth) && KnownZero.getBitWidth() == BitWidth && KnownOne.getBitWidth() == BitWidth && "V, Mask, KnownOne and KnownZero should have same BitWidth"); @@ -67,12 +68,26 @@ KnownZero = ~KnownOne & Mask; return; } - // Null is all-zeros. - if (isa(V)) { + // Null and aggregate-zero are all-zeros. + if (isa(V) || + isa(V)) { KnownOne.clear(); KnownZero = Mask; return; } + // Handle a constant vector by taking the intersection of the known bits of + // each element. + if (ConstantVector *CV = dyn_cast(V)) { + KnownZero.set(); KnownOne.set(); + for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) { + APInt KnownZero2(BitWidth, 0), KnownOne2(BitWidth, 0); + ComputeMaskedBits(CV->getOperand(i), Mask, KnownZero2, KnownOne2, + TD, Depth); + KnownZero &= KnownZero2; + KnownOne &= KnownOne2; + } + return; + } // The address of an aligned GlobalValue has trailing zeros. if (GlobalValue *GV = dyn_cast(V)) { unsigned Align = GV->getAlignment(); @@ -218,7 +233,7 @@ const Type *SrcTy = I->getOperand(0)->getType(); unsigned SrcBitWidth = TD ? TD->getTypeSizeInBits(SrcTy) : - SrcTy->getPrimitiveSizeInBits(); + SrcTy->getScalarSizeInBits(); APInt MaskIn(Mask); MaskIn.zextOrTrunc(SrcBitWidth); KnownZero.zextOrTrunc(SrcBitWidth); @@ -480,7 +495,7 @@ // Handle array index arithmetic. const Type *IndexedTy = GTI.getIndexedType(); if (!IndexedTy->isSized()) return; - unsigned GEPOpiBits = Index->getType()->getPrimitiveSizeInBits(); + unsigned GEPOpiBits = Index->getType()->getScalarSizeInBits(); uint64_t TypeSize = TD ? TD->getTypeAllocSize(IndexedTy) : 1; LocalMask = APInt::getAllOnesValue(GEPOpiBits); LocalKnownZero = LocalKnownOne = APInt(GEPOpiBits, 0); @@ -609,8 +624,8 @@ /// 'Op' must have a scalar integer type. /// unsigned llvm::ComputeNumSignBits(Value *V, TargetData *TD, unsigned Depth) { - const IntegerType *Ty = cast(V->getType()); - unsigned TyBits = Ty->getBitWidth(); + const Type *Ty = V->getType(); + unsigned TyBits = Ty->getScalarSizeInBits(); unsigned Tmp, Tmp2; unsigned FirstAnswer = 1; Modified: llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Mon Jun 15 17:12:54 2009 @@ -108,9 +108,9 @@ class VISIBILITY_HIDDEN GlobalRandomCounter : public Chooser { GlobalVariable* Counter; Value* ResetValue; - const Type* T; + const IntegerType* T; public: - GlobalRandomCounter(Module& M, const Type* t, uint64_t resetval); + GlobalRandomCounter(Module& M, const IntegerType* t, uint64_t resetval); virtual ~GlobalRandomCounter(); virtual void PrepFunction(Function* F); virtual void ProcessChoicePoint(BasicBlock* bb); @@ -121,9 +121,9 @@ GlobalVariable* Counter; Value* ResetValue; AllocaInst* AI; - const Type* T; + const IntegerType* T; public: - GlobalRandomCounterOpt(Module& M, const Type* t, uint64_t resetval); + GlobalRandomCounterOpt(Module& M, const IntegerType* t, uint64_t resetval); virtual ~GlobalRandomCounterOpt(); virtual void PrepFunction(Function* F); virtual void ProcessChoicePoint(BasicBlock* bb); @@ -193,7 +193,7 @@ // Methods of choosing when to profile /////////////////////////////////////// -GlobalRandomCounter::GlobalRandomCounter(Module& M, const Type* t, +GlobalRandomCounter::GlobalRandomCounter(Module& M, const IntegerType* t, uint64_t resetval) : T(t) { ConstantInt* Init = ConstantInt::get(T, resetval); ResetValue = Init; @@ -229,7 +229,7 @@ ReplacePhiPred(oldnext, bb, resetblock); } -GlobalRandomCounterOpt::GlobalRandomCounterOpt(Module& M, const Type* t, +GlobalRandomCounterOpt::GlobalRandomCounterOpt(Module& M, const IntegerType* t, uint64_t resetval) : AI(0), T(t) { ConstantInt* Init = ConstantInt::get(T, resetval); Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Jun 15 17:12:54 2009 @@ -390,7 +390,7 @@ Value *EvaluateInDifferentType(Value *V, const Type *Ty, bool isSigned); - bool CanEvaluateInDifferentType(Value *V, const IntegerType *Ty, + bool CanEvaluateInDifferentType(Value *V, const Type *Ty, unsigned CastOpc, int &NumCastsRemoved); unsigned GetOrEnforceKnownAlignment(Value *V, unsigned PrefAlign = 0); @@ -654,30 +654,12 @@ } /// AddOne - Add one to a ConstantInt -static ConstantInt *AddOne(ConstantInt *C) { - APInt Val(C->getValue()); - return ConstantInt::get(++Val); +static Constant *AddOne(Constant *C) { + return ConstantExpr::getAdd(C, ConstantInt::get(C->getType(), 1)); } /// SubOne - Subtract one from a ConstantInt -static ConstantInt *SubOne(ConstantInt *C) { - APInt Val(C->getValue()); - return ConstantInt::get(--Val); -} -/// Add - Add two ConstantInts together -static ConstantInt *Add(ConstantInt *C1, ConstantInt *C2) { - return ConstantInt::get(C1->getValue() + C2->getValue()); -} -/// And - Bitwise AND two ConstantInts together -static ConstantInt *And(ConstantInt *C1, ConstantInt *C2) { - return ConstantInt::get(C1->getValue() & C2->getValue()); -} -/// Subtract - Subtract one ConstantInt from another -static ConstantInt *Subtract(ConstantInt *C1, ConstantInt *C2) { - return ConstantInt::get(C1->getValue() - C2->getValue()); -} -/// Multiply - Multiply two ConstantInts together -static ConstantInt *Multiply(ConstantInt *C1, ConstantInt *C2) { - return ConstantInt::get(C1->getValue() * C2->getValue()); +static Constant *SubOne(ConstantInt *C) { + return ConstantExpr::getSub(C, ConstantInt::get(C->getType(), 1)); } /// MultiplyOverflows - True if the multiply can not be expressed in an int /// this size. @@ -774,7 +756,7 @@ /// SimplifyDemandedBits knows about. See if the instruction has any /// properties that allow us to simplify its operands. bool InstCombiner::SimplifyDemandedInstructionBits(Instruction &Inst) { - unsigned BitWidth = cast(Inst.getType())->getBitWidth(); + unsigned BitWidth = Inst.getType()->getScalarSizeInBits(); APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0); APInt DemandedMask(APInt::getAllOnesValue(BitWidth)); @@ -830,13 +812,13 @@ const Type *VTy = V->getType(); assert((TD || !isa(VTy)) && "SimplifyDemandedBits needs to know bit widths!"); - assert((!TD || TD->getTypeSizeInBits(VTy) == BitWidth) && - (!isa(VTy) || - VTy->getPrimitiveSizeInBits() == BitWidth) && + assert((!TD || TD->getTypeSizeInBits(VTy->getScalarType()) == BitWidth) && + (!VTy->isIntOrIntVector() || + VTy->getScalarSizeInBits() == BitWidth) && KnownZero.getBitWidth() == BitWidth && KnownOne.getBitWidth() == BitWidth && - "Value *V, DemandedMask, KnownZero and KnownOne \ - must have same BitWidth"); + "Value *V, DemandedMask, KnownZero and KnownOne " + "must have same BitWidth"); if (ConstantInt *CI = dyn_cast(V)) { // We know all of the bits for a constant! KnownOne = CI->getValue() & DemandedMask; @@ -1089,7 +1071,7 @@ RHSKnownZero &= LHSKnownZero; break; case Instruction::Trunc: { - unsigned truncBf = I->getOperand(0)->getType()->getPrimitiveSizeInBits(); + unsigned truncBf = I->getOperand(0)->getType()->getScalarSizeInBits(); DemandedMask.zext(truncBf); RHSKnownZero.zext(truncBf); RHSKnownOne.zext(truncBf); @@ -1112,7 +1094,7 @@ break; case Instruction::ZExt: { // Compute the bits in the result that are not present in the input. - unsigned SrcBitWidth =I->getOperand(0)->getType()->getPrimitiveSizeInBits(); + unsigned SrcBitWidth =I->getOperand(0)->getType()->getScalarSizeInBits(); DemandedMask.trunc(SrcBitWidth); RHSKnownZero.trunc(SrcBitWidth); @@ -1130,7 +1112,7 @@ } case Instruction::SExt: { // Compute the bits in the result that are not present in the input. - unsigned SrcBitWidth =I->getOperand(0)->getType()->getPrimitiveSizeInBits(); + unsigned SrcBitWidth =I->getOperand(0)->getType()->getScalarSizeInBits(); APInt InputDemandedBits = DemandedMask & APInt::getLowBitsSet(BitWidth, SrcBitWidth); @@ -2087,7 +2069,7 @@ // See if SimplifyDemandedBits can simplify this. This handles stuff like // (X & 254)+1 -> (X&254)|1 - if (!isa(I.getType()) && SimplifyDemandedInstructionBits(I)) + if (SimplifyDemandedInstructionBits(I)) return &I; // zext(i1) - 1 -> select i1, 0, -1 @@ -2107,7 +2089,7 @@ Value *XorLHS = 0; if (isa(RHSC) && match(LHS, m_Xor(m_Value(XorLHS), m_ConstantInt(XorRHS)))) { - uint32_t TySizeBits = I.getType()->getPrimitiveSizeInBits(); + uint32_t TySizeBits = I.getType()->getScalarSizeInBits(); const APInt& RHSVal = cast(RHSC)->getValue(); uint32_t Size = TySizeBits / 2; @@ -2197,7 +2179,7 @@ // X*C1 + X*C2 --> X * (C1+C2) ConstantInt *C1; if (X == dyn_castFoldableMul(RHS, C1)) - return BinaryOperator::CreateMul(X, Add(C1, C2)); + return BinaryOperator::CreateMul(X, ConstantExpr::getAdd(C1, C2)); } // X + X*C --> X * (C+1) @@ -2262,7 +2244,7 @@ // (X & FF00) + xx00 -> (X+xx00) & FF00 if (LHS->hasOneUse() && match(LHS, m_And(m_Value(X), m_ConstantInt(C2)))) { - Constant *Anded = And(CRHS, C2); + Constant *Anded = ConstantExpr::getAnd(CRHS, C2); if (Anded == CRHS) { // See if all bits from the first bit set in the Add RHS up are included // in the mask. First, get the rightmost bit. @@ -2299,7 +2281,7 @@ Other = LHS; } if (CI && CI->getType()->isSized() && - (CI->getType()->getPrimitiveSizeInBits() == + (CI->getType()->getScalarSizeInBits() == TD->getIntPtrType()->getPrimitiveSizeInBits()) && isa(CI->getOperand(0)->getType())) { unsigned AS = @@ -2523,7 +2505,7 @@ else if (ConstantInt *CI1 = dyn_cast(I.getOperand(0))) { if (ConstantInt *CI2 = dyn_cast(Op1I->getOperand(1))) // C1-(X+C2) --> (C1-C2)-X - return BinaryOperator::CreateSub(Subtract(CI1, CI2), + return BinaryOperator::CreateSub(ConstantExpr::getSub(CI1, CI2), Op1I->getOperand(0)); } } @@ -2564,7 +2546,8 @@ // X - X*C --> X * (1-C) ConstantInt *C2 = 0; if (dyn_castFoldableMul(Op1I, C2) == Op0) { - Constant *CP1 = Subtract(ConstantInt::get(I.getType(), 1), C2); + Constant *CP1 = ConstantExpr::getSub(ConstantInt::get(I.getType(), 1), + C2); return BinaryOperator::CreateMul(Op0, CP1); } } @@ -2589,7 +2572,7 @@ ConstantInt *C2; // X*C1 - X*C2 -> X * (C1-C2) if (X == dyn_castFoldableMul(Op1, C2)) - return BinaryOperator::CreateMul(X, Subtract(C1, C2)); + return BinaryOperator::CreateMul(X, ConstantExpr::getSub(C1, C2)); } return 0; } @@ -2950,12 +2933,12 @@ // (sdiv X, X) --> 1 (udiv X, X) --> 1 if (Op0 == Op1) { if (const VectorType *Ty = dyn_cast(I.getType())) { - ConstantInt *CI = ConstantInt::get(Ty->getElementType(), 1); + Constant *CI = ConstantInt::get(Ty->getElementType(), 1); std::vector Elts(Ty->getNumElements(), CI); return ReplaceInstUsesWith(I, ConstantVector::get(Elts)); } - ConstantInt *CI = ConstantInt::get(I.getType(), 1); + Constant *CI = ConstantInt::get(I.getType(), 1); return ReplaceInstUsesWith(I, CI); } @@ -2980,7 +2963,7 @@ return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); else return BinaryOperator::Create(I.getOpcode(), LHS->getOperand(0), - Multiply(RHS, LHSRHS)); + ConstantExpr::getMul(RHS, LHSRHS)); } if (!RHS->isZero()) { // avoid X udiv 0 @@ -3513,7 +3496,7 @@ Value *X = Op->getOperand(0); Constant *Together = 0; if (!Op->isShift()) - Together = And(AndRHS, OpRHS); + Together = ConstantExpr::getAnd(AndRHS, OpRHS); switch (Op->getOpcode()) { case Instruction::Xor: @@ -3724,7 +3707,7 @@ switch (LHSI->getOpcode()) { default: return 0; case Instruction::And: - if (And(N, Mask) == Mask) { + if (ConstantExpr::getAnd(N, Mask) == Mask) { // If the AndRHS is a power of two minus one (0+1+), this is simple. if ((Mask->getValue().countLeadingZeros() + Mask->getValue().countPopulation()) == @@ -3748,7 +3731,7 @@ // If the AndRHS is a power of two minus one (0+1+), and N&Mask == 0 if ((Mask->getValue().countLeadingZeros() + Mask->getValue().countPopulation()) == Mask->getValue().getBitWidth() - && And(N, Mask)->isZero()) + && ConstantExpr::getAnd(N, Mask)->isNullValue()) break; return 0; } @@ -3946,10 +3929,9 @@ // See if we can simplify any instructions used by the instruction whose sole // purpose is to compute bits we don't care about. - if (!isa(I.getType())) { - if (SimplifyDemandedInstructionBits(I)) - return &I; - } else { + if (SimplifyDemandedInstructionBits(I)) + return &I; + if (isa(I.getType())) { if (ConstantVector *CP = dyn_cast(Op1)) { if (CP->isAllOnesValue()) // X & <-1,-1> -> X return ReplaceInstUsesWith(I, I.getOperand(0)); @@ -3957,7 +3939,7 @@ return ReplaceInstUsesWith(I, Op1); // X & <0,0> -> <0,0> } } - + if (ConstantInt *AndRHS = dyn_cast(Op1)) { const APInt& AndRHSMask = AndRHS->getValue(); APInt NotAndRHS(~AndRHSMask); @@ -4510,7 +4492,7 @@ Instruction *Add = BinaryOperator::CreateAdd(Val, AddCST, Val->getName()+".off"); InsertNewInstBefore(Add, I); - AddCST = Subtract(AddOne(RHSCst), LHSCst); + AddCST = ConstantExpr::getSub(AddOne(RHSCst), LHSCst); return new ICmpInst(ICmpInst::ICMP_ULT, Add, AddCST); } break; // (X == 13 | X == 15) -> no change @@ -4653,18 +4635,17 @@ // See if we can simplify any instructions used by the instruction whose sole // purpose is to compute bits we don't care about. - if (!isa(I.getType())) { - if (SimplifyDemandedInstructionBits(I)) - return &I; - } else if (isa(Op1)) { - return ReplaceInstUsesWith(I, Op0); // X | <0,0> -> X - } else if (ConstantVector *CP = dyn_cast(Op1)) { - if (CP->isAllOnesValue()) // X | <-1,-1> -> <-1,-1> - return ReplaceInstUsesWith(I, I.getOperand(1)); + if (SimplifyDemandedInstructionBits(I)) + return &I; + if (isa(I.getType())) { + if (isa(Op1)) { + return ReplaceInstUsesWith(I, Op0); // X | <0,0> -> X + } else if (ConstantVector *CP = dyn_cast(Op1)) { + if (CP->isAllOnesValue()) // X | <-1,-1> -> <-1,-1> + return ReplaceInstUsesWith(I, I.getOperand(1)); + } } - - // or X, -1 == -1 if (ConstantInt *RHS = dyn_cast(Op1)) { ConstantInt *C1 = 0; Value *X = 0; @@ -4991,12 +4972,11 @@ // See if we can simplify any instructions used by the instruction whose sole // purpose is to compute bits we don't care about. - if (!isa(I.getType())) { - if (SimplifyDemandedInstructionBits(I)) - return &I; - } else if (isa(Op1)) { - return ReplaceInstUsesWith(I, Op0); // X ^ <0,0> -> X - } + if (SimplifyDemandedInstructionBits(I)) + return &I; + if (isa(I.getType())) + if (isa(Op1)) + return ReplaceInstUsesWith(I, Op0); // X ^ <0,0> -> X // Is this a ~ operation? if (Value *NotOp = dyn_castNotVal(&I)) { @@ -5083,7 +5063,7 @@ Constant *NewRHS = ConstantExpr::getOr(Op0CI, RHS); // Anything in both C1 and C2 is known to be zero, remove it from // NewRHS. - Constant *CommonBits = And(Op0CI, RHS); + Constant *CommonBits = ConstantExpr::getAnd(Op0CI, RHS); NewRHS = ConstantExpr::getAnd(NewRHS, ConstantExpr::getNot(CommonBits)); AddToWorkList(Op0I); @@ -5247,12 +5227,13 @@ return Changed ? &I : 0; } -/// AddWithOverflow - Compute Result = In1+In2, returning true if the result -/// overflowed for this type. -static bool AddWithOverflow(ConstantInt *&Result, ConstantInt *In1, - ConstantInt *In2, bool IsSigned = false) { - Result = cast(Add(In1, In2)); +static ConstantInt *ExtractElement(Constant *V, Constant *Idx) { + return cast(ConstantExpr::getExtractElement(V, Idx)); +} +static bool HasAddOverflow(ConstantInt *Result, + ConstantInt *In1, ConstantInt *In2, + bool IsSigned) { if (IsSigned) if (In2->getValue().isNegative()) return Result->getValue().sgt(In1->getValue()); @@ -5262,12 +5243,32 @@ return Result->getValue().ult(In1->getValue()); } -/// SubWithOverflow - Compute Result = In1-In2, returning true if the result +/// AddWithOverflow - Compute Result = In1+In2, returning true if the result /// overflowed for this type. -static bool SubWithOverflow(ConstantInt *&Result, ConstantInt *In1, - ConstantInt *In2, bool IsSigned = false) { - Result = cast(Subtract(In1, In2)); +static bool AddWithOverflow(Constant *&Result, Constant *In1, + Constant *In2, bool IsSigned = false) { + Result = ConstantExpr::getAdd(In1, In2); + + if (const VectorType *VTy = dyn_cast(In1->getType())) { + for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { + Constant *Idx = ConstantInt::get(Type::Int32Ty, i); + if (HasAddOverflow(ExtractElement(Result, Idx), + ExtractElement(In1, Idx), + ExtractElement(In2, Idx), + IsSigned)) + return true; + } + return false; + } + + return HasAddOverflow(cast(Result), + cast(In1), cast(In2), + IsSigned); +} +static bool HasSubOverflow(ConstantInt *Result, + ConstantInt *In1, ConstantInt *In2, + bool IsSigned) { if (IsSigned) if (In2->getValue().isNegative()) return Result->getValue().slt(In1->getValue()); @@ -5277,6 +5278,29 @@ return Result->getValue().ugt(In1->getValue()); } +/// SubWithOverflow - Compute Result = In1-In2, returning true if the result +/// overflowed for this type. +static bool SubWithOverflow(Constant *&Result, Constant *In1, + Constant *In2, bool IsSigned = false) { + Result = ConstantExpr::getSub(In1, In2); + + if (const VectorType *VTy = dyn_cast(In1->getType())) { + for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { + Constant *Idx = ConstantInt::get(Type::Int32Ty, i); + if (HasSubOverflow(ExtractElement(Result, Idx), + ExtractElement(In1, Idx), + ExtractElement(In2, Idx), + IsSigned)) + return true; + } + return false; + } + + return HasSubOverflow(cast(Result), + cast(In1), cast(In2), + IsSigned); +} + /// EmitGEPOffset - Given a getelementptr instruction/constantexpr, emit the /// code necessary to compute the offset from the base pointer (without adding /// in the base pointer). Return the result as a signed integer of intptr size. @@ -5589,7 +5613,7 @@ // Check to see that the input is converted from an integer type that is small // enough that preserves all bits. TODO: check here for "known" sign bits. // This would allow us to handle (fptosi (x >>s 62) to float) if x is i64 f.e. - unsigned InputSize = LHSI->getOperand(0)->getType()->getPrimitiveSizeInBits(); + unsigned InputSize = LHSI->getOperand(0)->getType()->getScalarSizeInBits(); // If this is a uitofp instruction, we need an extra bit to hold the sign. bool LHSUnsigned = isa(LHSI); @@ -5644,7 +5668,7 @@ // See if the FP constant is too large for the integer. For example, // comparing an i8 to 300.0. - unsigned IntWidth = IntTy->getPrimitiveSizeInBits(); + unsigned IntWidth = IntTy->getScalarSizeInBits(); if (!LHSUnsigned) { // If the RHS value is > SignedMax, fold the comparison. This handles +INF @@ -6459,7 +6483,7 @@ // of form X/C1=C2. We solve for X by multiplying C1 (DivRHS) and // C2 (CI). By solving for X we can turn this into a range check // instead of computing a divide. - ConstantInt *Prod = Multiply(CmpRHS, DivRHS); + Constant *Prod = ConstantExpr::getMul(CmpRHS, DivRHS); // Determine if the product overflows by seeing if the product is // not equal to the divide. Make sure we do the same kind of divide @@ -6478,7 +6502,7 @@ // overflow variable is set to 0 if it's corresponding bound variable is valid // -1 if overflowed off the bottom end, or +1 if overflowed off the top end. int LoOverflow = 0, HiOverflow = 0; - ConstantInt *LoBound = 0, *HiBound = 0; + Constant *LoBound = 0, *HiBound = 0; if (!DivIsSigned) { // udiv // e.g. X/5 op 3 --> [15, 20) @@ -6966,7 +6990,7 @@ if (ConstantInt *BOp1C = dyn_cast(BO->getOperand(1))) { if (BO->hasOneUse()) return new ICmpInst(ICI.getPredicate(), BO->getOperand(0), - Subtract(RHS, BOp1C)); + ConstantExpr::getSub(RHS, BOp1C)); } else if (RHSV == 0) { // Replace ((add A, B) != 0) with (A != -B) if A or B is // efficiently invertible, or if the add has just this one use. @@ -7250,7 +7274,7 @@ } // See if we can fold away this shift. - if (!isa(I.getType()) && SimplifyDemandedInstructionBits(I)) + if (SimplifyDemandedInstructionBits(I)) return &I; // Try to fold constant and into select arguments. @@ -7729,7 +7753,8 @@ // If the allocation size is constant, form a constant mul expression Amt = ConstantInt::get(Type::Int32Ty, Scale); if (isa(NumElements)) - Amt = Multiply(cast(NumElements), cast(Amt)); + Amt = ConstantExpr::getMul(cast(NumElements), + cast(Amt)); // otherwise multiply the amount and the number of elements else { Instruction *Tmp = BinaryOperator::CreateMul(Amt, NumElements, "tmp"); @@ -7788,17 +7813,17 @@ /// If CastOpc is a sext or zext, we are asking if the low bits of the value can /// bit computed in a larger type, which is then and'd or sext_in_reg'd to get /// the final result. -bool InstCombiner::CanEvaluateInDifferentType(Value *V, const IntegerType *Ty, +bool InstCombiner::CanEvaluateInDifferentType(Value *V, const Type *Ty, unsigned CastOpc, int &NumCastsRemoved){ // We can always evaluate constants in another type. - if (isa(V)) + if (isa(V)) return true; Instruction *I = dyn_cast(V); if (!I) return false; - const IntegerType *OrigTy = cast(V->getType()); + const Type *OrigTy = V->getType(); // If this is an extension or truncate, we can often eliminate it. if (isa(I) || isa(I) || isa(I)) { @@ -7836,8 +7861,8 @@ // If we are truncating the result of this SHL, and if it's a shift of a // constant amount, we can always perform a SHL in a smaller type. if (ConstantInt *CI = dyn_cast(I->getOperand(1))) { - uint32_t BitWidth = Ty->getBitWidth(); - if (BitWidth < OrigTy->getBitWidth() && + uint32_t BitWidth = Ty->getScalarSizeInBits(); + if (BitWidth < OrigTy->getScalarSizeInBits() && CI->getLimitedValue(BitWidth) < BitWidth) return CanEvaluateInDifferentType(I->getOperand(0), Ty, CastOpc, NumCastsRemoved); @@ -7848,8 +7873,8 @@ // lshr iff we know that the bits we would otherwise be shifting in are // already zeros. if (ConstantInt *CI = dyn_cast(I->getOperand(1))) { - uint32_t OrigBitWidth = OrigTy->getBitWidth(); - uint32_t BitWidth = Ty->getBitWidth(); + uint32_t OrigBitWidth = OrigTy->getScalarSizeInBits(); + uint32_t BitWidth = Ty->getScalarSizeInBits(); if (BitWidth < OrigBitWidth && MaskedValueIsZero(I->getOperand(0), APInt::getHighBitsSet(OrigBitWidth, OrigBitWidth-BitWidth)) && @@ -8131,8 +8156,8 @@ Value *Src = CI.getOperand(0); const Type *SrcTy = Src->getType(); const Type *DestTy = CI.getType(); - uint32_t SrcBitSize = SrcTy->getPrimitiveSizeInBits(); - uint32_t DestBitSize = DestTy->getPrimitiveSizeInBits(); + uint32_t SrcBitSize = SrcTy->getScalarSizeInBits(); + uint32_t DestBitSize = DestTy->getScalarSizeInBits(); // See if we can simplify any instructions used by the LHS whose sole // purpose is to compute bits we don't care about. @@ -8151,8 +8176,9 @@ // Only do this if the dest type is a simple type, don't convert the // expression tree to something weird like i93 unless the source is also // strange. - (isSafeIntegerType(DestTy) || !isSafeIntegerType(SrcI->getType())) && - CanEvaluateInDifferentType(SrcI, cast(DestTy), + (isSafeIntegerType(DestTy->getScalarType()) || + !isSafeIntegerType(SrcI->getType()->getScalarType())) && + CanEvaluateInDifferentType(SrcI, DestTy, CI.getOpcode(), NumCastsRemoved)) { // If this cast is a truncate, evaluting in a different type always // eliminates the cast, so it is always a win. If this is a zero-extension, @@ -8350,17 +8376,17 @@ Value *Src = CI.getOperand(0); const Type *Ty = CI.getType(); - uint32_t DestBitWidth = Ty->getPrimitiveSizeInBits(); - uint32_t SrcBitWidth = cast(Src->getType())->getBitWidth(); + uint32_t DestBitWidth = Ty->getScalarSizeInBits(); + uint32_t SrcBitWidth = Src->getType()->getScalarSizeInBits(); // Canonicalize trunc x to i1 -> (icmp ne (and x, 1), 0) - if (DestBitWidth == 1) { + if (!isa(Ty) && DestBitWidth == 1) { Constant *One = ConstantInt::get(Src->getType(), 1); Src = InsertNewInstBefore(BinaryOperator::CreateAnd(Src, One, "tmp"), CI); Value *Zero = Constant::getNullValue(Src->getType()); return new ICmpInst(ICmpInst::ICMP_NE, Src, Zero); } - + // Optimize trunc(lshr(), c) to pull the shift through the truncate. ConstantInt *ShAmtV = 0; Value *ShiftOp = 0; @@ -8403,7 +8429,7 @@ Value *In = ICI->getOperand(0); Value *Sh = ConstantInt::get(In->getType(), - In->getType()->getPrimitiveSizeInBits()-1); + In->getType()->getScalarSizeInBits()-1); In = InsertNewInstBefore(BinaryOperator::CreateLShr(In, Sh, In->getName()+".lobit"), CI); @@ -8494,28 +8520,30 @@ // Get the sizes of the types involved. We know that the intermediate type // will be smaller than A or C, but don't know the relation between A and C. Value *A = CSrc->getOperand(0); - unsigned SrcSize = A->getType()->getPrimitiveSizeInBits(); - unsigned MidSize = CSrc->getType()->getPrimitiveSizeInBits(); - unsigned DstSize = CI.getType()->getPrimitiveSizeInBits(); + unsigned SrcSize = A->getType()->getScalarSizeInBits(); + unsigned MidSize = CSrc->getType()->getScalarSizeInBits(); + unsigned DstSize = CI.getType()->getScalarSizeInBits(); // If we're actually extending zero bits, then if // SrcSize < DstSize: zext(a & mask) // SrcSize == DstSize: a & mask // SrcSize > DstSize: trunc(a) & mask if (SrcSize < DstSize) { APInt AndValue(APInt::getLowBitsSet(SrcSize, MidSize)); - Constant *AndConst = ConstantInt::get(AndValue); + Constant *AndConst = ConstantInt::get(A->getType(), AndValue); Instruction *And = BinaryOperator::CreateAnd(A, AndConst, CSrc->getName()+".mask"); InsertNewInstBefore(And, CI); return new ZExtInst(And, CI.getType()); } else if (SrcSize == DstSize) { APInt AndValue(APInt::getLowBitsSet(SrcSize, MidSize)); - return BinaryOperator::CreateAnd(A, ConstantInt::get(AndValue)); + return BinaryOperator::CreateAnd(A, ConstantInt::get(A->getType(), + AndValue)); } else if (SrcSize > DstSize) { Instruction *Trunc = new TruncInst(A, CI.getType(), "tmp"); InsertNewInstBefore(Trunc, CI); APInt AndValue(APInt::getLowBitsSet(DstSize, MidSize)); - return BinaryOperator::CreateAnd(Trunc, ConstantInt::get(AndValue)); + return BinaryOperator::CreateAnd(Trunc, ConstantInt::get(Trunc->getType(), + AndValue)); } } @@ -8556,9 +8584,9 @@ // eliminate the trunc/sext pair. if (getOpcode(Src) == Instruction::Trunc) { Value *Op = cast(Src)->getOperand(0); - unsigned OpBits = cast(Op->getType())->getBitWidth(); - unsigned MidBits = cast(Src->getType())->getBitWidth(); - unsigned DestBits = cast(CI.getType())->getBitWidth(); + unsigned OpBits = Op->getType()->getScalarSizeInBits(); + unsigned MidBits = Src->getType()->getScalarSizeInBits(); + unsigned DestBits = CI.getType()->getScalarSizeInBits(); unsigned NumSignBits = ComputeNumSignBits(Op); if (OpBits == DestBits) { @@ -8599,8 +8627,8 @@ BA == CA && isa(A)) { Value *I = cast(A)->getOperand(0); if (I->getType() == CI.getType()) { - unsigned MidSize = Src->getType()->getPrimitiveSizeInBits(); - unsigned SrcDstSize = CI.getType()->getPrimitiveSizeInBits(); + unsigned MidSize = Src->getType()->getScalarSizeInBits(); + unsigned SrcDstSize = CI.getType()->getScalarSizeInBits(); unsigned ShAmt = CA->getZExtValue()+SrcDstSize-MidSize; Constant *ShAmtV = ConstantInt::get(CI.getType(), ShAmt); I = InsertNewInstBefore(BinaryOperator::CreateShl(I, ShAmtV, @@ -8671,11 +8699,11 @@ Value *RHSTrunc = LookThroughFPExtensions(OpI->getOperand(1)); if (LHSTrunc->getType() != SrcTy && RHSTrunc->getType() != SrcTy) { - unsigned DstSize = CI.getType()->getPrimitiveSizeInBits(); + unsigned DstSize = CI.getType()->getScalarSizeInBits(); // If the source types were both smaller than the destination type of // the cast, do this xform. - if (LHSTrunc->getType()->getPrimitiveSizeInBits() <= DstSize && - RHSTrunc->getType()->getPrimitiveSizeInBits() <= DstSize) { + if (LHSTrunc->getType()->getScalarSizeInBits() <= DstSize && + RHSTrunc->getType()->getScalarSizeInBits() <= DstSize) { LHSTrunc = InsertCastBefore(Instruction::FPExt, LHSTrunc, CI.getType(), CI); RHSTrunc = InsertCastBefore(Instruction::FPExt, RHSTrunc, @@ -8706,7 +8734,7 @@ // 'X' value would cause an undefined result for the fptoui. if ((isa(OpI) || isa(OpI)) && OpI->getOperand(0)->getType() == FI.getType() && - (int)FI.getType()->getPrimitiveSizeInBits() < /*extra bit for sign */ + (int)FI.getType()->getScalarSizeInBits() < /*extra bit for sign */ OpI->getType()->getFPMantissaWidth()) return ReplaceInstUsesWith(FI, OpI->getOperand(0)); @@ -8726,7 +8754,7 @@ // 'X' value would cause an undefined result for the fptoui. if ((isa(OpI) || isa(OpI)) && OpI->getOperand(0)->getType() == FI.getType() && - (int)FI.getType()->getPrimitiveSizeInBits() <= + (int)FI.getType()->getScalarSizeInBits() <= OpI->getType()->getFPMantissaWidth()) return ReplaceInstUsesWith(FI, OpI->getOperand(0)); @@ -8747,7 +8775,7 @@ // trunc to be exposed to other transforms. Don't do this for extending // ptrtoint's, because we don't know if the target sign or zero extends its // pointers. - if (CI.getType()->getPrimitiveSizeInBits() < TD->getPointerSizeInBits()) { + if (CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits()) { Value *P = InsertNewInstBefore(new PtrToIntInst(CI.getOperand(0), TD->getIntPtrType(), "tmp"), CI); @@ -8763,7 +8791,7 @@ // allows the trunc to be exposed to other transforms. Don't do this for // extending inttoptr's, because we don't know if the target sign or zero // extends to pointers. - if (CI.getOperand(0)->getType()->getPrimitiveSizeInBits() > + if (CI.getOperand(0)->getType()->getScalarSizeInBits() > TD->getPointerSizeInBits()) { Value *P = InsertNewInstBefore(new TruncInst(CI.getOperand(0), TD->getIntPtrType(), @@ -9194,7 +9222,7 @@ (Pred == ICmpInst::ICMP_SGT && Op1CV.isAllOnesValue())) { Value *In = ICI->getOperand(0); Value *Sh = ConstantInt::get(In->getType(), - In->getType()->getPrimitiveSizeInBits()-1); + In->getType()->getScalarSizeInBits()-1); In = InsertNewInstBefore(BinaryOperator::CreateAShr(In, Sh, In->getName()+".lobit"), *ICI); @@ -9316,7 +9344,7 @@ // The comparison constant and the result are not neccessarily the // same width. Make an all-ones value by inserting a AShr. Value *X = IC->getOperand(0); - uint32_t Bits = X->getType()->getPrimitiveSizeInBits(); + uint32_t Bits = X->getType()->getScalarSizeInBits(); Constant *ShAmt = ConstantInt::get(X->getType(), Bits-1); Instruction *SRA = BinaryOperator::Create(Instruction::AShr, X, ShAmt, "ones"); @@ -10850,8 +10878,8 @@ static Value *InsertCastToIntPtrTy(Value *V, const Type *DTy, Instruction *InsertPoint, InstCombiner *IC) { - unsigned PtrSize = DTy->getPrimitiveSizeInBits(); - unsigned VTySize = V->getType()->getPrimitiveSizeInBits(); + unsigned PtrSize = DTy->getScalarSizeInBits(); + unsigned VTySize = V->getType()->getScalarSizeInBits(); // We must cast correctly to the pointer type. Ensure that we // sign extend the integer value if it is smaller as this is // used for address computation. @@ -10892,7 +10920,7 @@ const Type *SrcTy = CI->getOperand(0)->getType(); // We can eliminate a cast from i32 to i64 iff the target // is a 32-bit pointer target. - if (SrcTy->getPrimitiveSizeInBits() >= TD->getPointerSizeInBits()) { + if (SrcTy->getScalarSizeInBits() >= TD->getPointerSizeInBits()) { MadeChange = true; *i = CI->getOperand(0); } @@ -11105,7 +11133,7 @@ ConstantInt *Scale = 0; if (ArrayEltSize == 1) { NewIdx = GEP.getOperand(1); - Scale = ConstantInt::get(NewIdx->getType(), 1); + Scale = ConstantInt::get(cast(NewIdx->getType()), 1); } else if (ConstantInt *CI = dyn_cast(GEP.getOperand(1))) { NewIdx = ConstantInt::get(CI->getType(), 1); Scale = CI; @@ -11114,7 +11142,8 @@ isa(Inst->getOperand(1))) { ConstantInt *ShAmt = cast(Inst->getOperand(1)); uint32_t ShAmtVal = ShAmt->getLimitedValue(64); - Scale = ConstantInt::get(Inst->getType(), 1ULL << ShAmtVal); + Scale = ConstantInt::get(cast(Inst->getType()), + 1ULL << ShAmtVal); NewIdx = Inst->getOperand(0); } else if (Inst->getOpcode() == Instruction::Mul && isa(Inst->getOperand(1))) { Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Mon Jun 15 17:12:54 2009 @@ -290,13 +290,13 @@ // Return V+1 static Value *getPlusOne(Value *V, bool Sign, Instruction *InsertPt) { - ConstantInt *One = ConstantInt::get(V->getType(), 1, Sign); + Constant *One = ConstantInt::get(V->getType(), 1, Sign); return BinaryOperator::CreateAdd(V, One, "lsp", InsertPt); } // Return V-1 static Value *getMinusOne(Value *V, bool Sign, Instruction *InsertPt) { - ConstantInt *One = ConstantInt::get(V->getType(), 1, Sign); + Constant *One = ConstantInt::get(V->getType(), 1, Sign); return BinaryOperator::CreateSub(V, One, "lsp", InsertPt); } Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon Jun 15 17:12:54 2009 @@ -2008,15 +2008,15 @@ if (!isa(NewCmpTy)) NewCmpRHS = ConstantInt::get(NewCmpTy, NewCmpVal); else { - ConstantInt *CI = ConstantInt::get(NewCmpIntTy, NewCmpVal); + Constant *CI = ConstantInt::get(NewCmpIntTy, NewCmpVal); NewCmpRHS = ConstantExpr::getIntToPtr(CI, NewCmpTy); } NewOffset = TyBits == NewTyBits ? SE->getMulExpr(CondUse->getOffset(), - SE->getConstant(ConstantInt::get(CmpTy, Scale))) - : SE->getConstant(ConstantInt::get(NewCmpIntTy, + SE->getConstant(CmpTy, Scale)) + : SE->getConstant(NewCmpIntTy, cast(CondUse->getOffset())->getValue() - ->getSExtValue()*Scale)); + ->getSExtValue()*Scale); break; } } @@ -2242,7 +2242,7 @@ ConstantInt *Init = dyn_cast(PH->getIncomingValue(Entry)); if (!Init) continue; - ConstantFP *NewInit = ConstantFP::get(DestTy, Init->getZExtValue()); + Constant *NewInit = ConstantFP::get(DestTy, Init->getZExtValue()); BinaryOperator *Incr = dyn_cast(PH->getIncomingValue(Latch)); @@ -2266,7 +2266,7 @@ PHINode *NewPH = PHINode::Create(DestTy, "IV.S.", PH); /* create new increment. '++d' in above example. */ - ConstantFP *CFP = ConstantFP::get(DestTy, C->getZExtValue()); + Constant *CFP = ConstantFP::get(DestTy, C->getZExtValue()); BinaryOperator *NewIncr = BinaryOperator::Create(Incr->getOpcode() == Instruction::Add ? Instruction::FAdd : Instruction::FSub, @@ -2506,7 +2506,7 @@ Value *startVal = phi->getIncomingValue(inBlock); Value *endVal = Cond->getOperand(1); // FIXME check for case where both are constant - ConstantInt* Zero = ConstantInt::get(Cond->getOperand(1)->getType(), 0); + Constant* Zero = ConstantInt::get(Cond->getOperand(1)->getType(), 0); BinaryOperator *NewStartVal = BinaryOperator::Create(Instruction::Sub, endVal, startVal, "tmp", PreInsertPt); Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Mon Jun 15 17:12:54 2009 @@ -208,6 +208,22 @@ } } + // If the cast operand is a constant vector, perform the cast by + // operating on each element. In the cast of bitcasts, the element + // count may be mismatched; don't attempt to handle that here. + if (const ConstantVector *CV = dyn_cast(V)) + if (isa(DestTy) && + cast(DestTy)->getNumElements() == + CV->getType()->getNumElements()) { + std::vector res; + const VectorType *DestVecTy = cast(DestTy); + const Type *DstEltTy = DestVecTy->getElementType(); + for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) + res.push_back(ConstantExpr::getCast(opc, + CV->getOperand(i), DstEltTy)); + return ConstantVector::get(DestVecTy, res); + } + // We actually have to do a cast now. Perform the cast according to the // opcode specified. switch (opc) { @@ -237,14 +253,6 @@ APInt Val(DestBitWidth, 2, x); return ConstantInt::get(Val); } - if (const ConstantVector *CV = dyn_cast(V)) { - std::vector res; - const VectorType *DestVecTy = cast(DestTy); - const Type *DstEltTy = DestVecTy->getElementType(); - for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) - res.push_back(ConstantExpr::getCast(opc, CV->getOperand(i), DstEltTy)); - return ConstantVector::get(DestVecTy, res); - } return 0; // Can't fold. case Instruction::IntToPtr: //always treated as unsigned if (V->isNullValue()) // Is it an integral null value? @@ -266,14 +274,6 @@ APFloat::rmNearestTiesToEven); return ConstantFP::get(apf); } - if (const ConstantVector *CV = dyn_cast(V)) { - std::vector res; - const VectorType *DestVecTy = cast(DestTy); - const Type *DstEltTy = DestVecTy->getElementType(); - for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) - res.push_back(ConstantExpr::getCast(opc, CV->getOperand(i), DstEltTy)); - return ConstantVector::get(DestVecTy, res); - } return 0; case Instruction::ZExt: if (const ConstantInt *CI = dyn_cast(V)) { Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Mon Jun 15 17:12:54 2009 @@ -269,9 +269,20 @@ DenseMapAPIntKeyInfo> IntMapTy; static ManagedStatic IntConstants; -ConstantInt *ConstantInt::get(const Type *Ty, uint64_t V, bool isSigned) { - const IntegerType *ITy = cast(Ty); - return get(APInt(ITy->getBitWidth(), V, isSigned)); +ConstantInt *ConstantInt::get(const IntegerType *Ty, + uint64_t V, bool isSigned) { + return get(APInt(Ty->getBitWidth(), V, isSigned)); +} + +Constant *ConstantInt::get(const Type *Ty, uint64_t V, bool isSigned) { + Constant *C = get(cast(Ty->getScalarType()), V, isSigned); + + // For vectors, broadcast the value. + if (const VectorType *VTy = dyn_cast(Ty)) + return + ConstantVector::get(std::vector(VTy->getNumElements(), C)); + + return C; } // Get a ConstantInt from an APInt. Note that the value stored in the DenseMap @@ -292,6 +303,19 @@ return Slot = new ConstantInt(ITy, V); } +Constant *ConstantInt::get(const Type *Ty, const APInt &V) { + ConstantInt *C = ConstantInt::get(V); + assert(C->getType() == Ty->getScalarType() && + "ConstantInt type doesn't match the type implied by its value!"); + + // For vectors, broadcast the value. + if (const VectorType *VTy = dyn_cast(Ty)) + return + ConstantVector::get(std::vector(VTy->getNumElements(), C)); + + return C; +} + //===----------------------------------------------------------------------===// // ConstantFP //===----------------------------------------------------------------------===// @@ -391,11 +415,19 @@ /// get() - This returns a constant fp for the specified value in the /// specified type. This should only be used for simple constant values like /// 2.0/1.0 etc, that are known-valid both as double and as the target format. -ConstantFP *ConstantFP::get(const Type *Ty, double V) { +Constant *ConstantFP::get(const Type *Ty, double V) { APFloat FV(V); bool ignored; - FV.convert(*TypeToFloatSemantics(Ty), APFloat::rmNearestTiesToEven, &ignored); - return get(FV); + FV.convert(*TypeToFloatSemantics(Ty->getScalarType()), + APFloat::rmNearestTiesToEven, &ignored); + Constant *C = get(FV); + + // For vectors, broadcast the value. + if (const VectorType *VTy = dyn_cast(Ty)) + return + ConstantVector::get(std::vector(VTy->getNumElements(), C)); + + return C; } //===----------------------------------------------------------------------===// @@ -1932,19 +1964,19 @@ } Constant *ConstantExpr::getZExtOrBitCast(Constant *C, const Type *Ty) { - if (C->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) + if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) return getCast(Instruction::BitCast, C, Ty); return getCast(Instruction::ZExt, C, Ty); } Constant *ConstantExpr::getSExtOrBitCast(Constant *C, const Type *Ty) { - if (C->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) + if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) return getCast(Instruction::BitCast, C, Ty); return getCast(Instruction::SExt, C, Ty); } Constant *ConstantExpr::getTruncOrBitCast(Constant *C, const Type *Ty) { - if (C->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) + if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) return getCast(Instruction::BitCast, C, Ty); return getCast(Instruction::Trunc, C, Ty); } @@ -1960,9 +1992,10 @@ Constant *ConstantExpr::getIntegerCast(Constant *C, const Type *Ty, bool isSigned) { - assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast"); - unsigned SrcBits = C->getType()->getPrimitiveSizeInBits(); - unsigned DstBits = Ty->getPrimitiveSizeInBits(); + assert(C->getType()->isIntOrIntVector() && + Ty->isIntOrIntVector() && "Invalid cast"); + unsigned SrcBits = C->getType()->getScalarSizeInBits(); + unsigned DstBits = Ty->getScalarSizeInBits(); Instruction::CastOps opcode = (SrcBits == DstBits ? Instruction::BitCast : (SrcBits > DstBits ? Instruction::Trunc : @@ -1971,10 +2004,10 @@ } Constant *ConstantExpr::getFPCast(Constant *C, const Type *Ty) { - assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && + assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && "Invalid cast"); - unsigned SrcBits = C->getType()->getPrimitiveSizeInBits(); - unsigned DstBits = Ty->getPrimitiveSizeInBits(); + unsigned SrcBits = C->getType()->getScalarSizeInBits(); + unsigned DstBits = Ty->getScalarSizeInBits(); if (SrcBits == DstBits) return C; // Avoid a useless cast Instruction::CastOps opcode = @@ -1983,42 +2016,67 @@ } Constant *ConstantExpr::getTrunc(Constant *C, const Type *Ty) { - assert(C->getType()->isInteger() && "Trunc operand must be integer"); - assert(Ty->isInteger() && "Trunc produces only integral"); - assert(C->getType()->getPrimitiveSizeInBits() > Ty->getPrimitiveSizeInBits()&& +#ifndef NDEBUG + bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; + bool toVec = Ty->getTypeID() == Type::VectorTyID; +#endif + assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); + assert(C->getType()->isIntOrIntVector() && "Trunc operand must be integer"); + assert(Ty->isIntOrIntVector() && "Trunc produces only integral"); + assert(C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& "SrcTy must be larger than DestTy for Trunc!"); return getFoldedCast(Instruction::Trunc, C, Ty); } Constant *ConstantExpr::getSExt(Constant *C, const Type *Ty) { - assert(C->getType()->isInteger() && "SEXt operand must be integral"); - assert(Ty->isInteger() && "SExt produces only integer"); - assert(C->getType()->getPrimitiveSizeInBits() < Ty->getPrimitiveSizeInBits()&& +#ifndef NDEBUG + bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; + bool toVec = Ty->getTypeID() == Type::VectorTyID; +#endif + assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); + assert(C->getType()->isIntOrIntVector() && "SExt operand must be integral"); + assert(Ty->isIntOrIntVector() && "SExt produces only integer"); + assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "SrcTy must be smaller than DestTy for SExt!"); return getFoldedCast(Instruction::SExt, C, Ty); } Constant *ConstantExpr::getZExt(Constant *C, const Type *Ty) { - assert(C->getType()->isInteger() && "ZEXt operand must be integral"); - assert(Ty->isInteger() && "ZExt produces only integer"); - assert(C->getType()->getPrimitiveSizeInBits() < Ty->getPrimitiveSizeInBits()&& +#ifndef NDEBUG + bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; + bool toVec = Ty->getTypeID() == Type::VectorTyID; +#endif + assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); + assert(C->getType()->isIntOrIntVector() && "ZEXt operand must be integral"); + assert(Ty->isIntOrIntVector() && "ZExt produces only integer"); + assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "SrcTy must be smaller than DestTy for ZExt!"); return getFoldedCast(Instruction::ZExt, C, Ty); } Constant *ConstantExpr::getFPTrunc(Constant *C, const Type *Ty) { - assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && - C->getType()->getPrimitiveSizeInBits() > Ty->getPrimitiveSizeInBits()&& +#ifndef NDEBUG + bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; + bool toVec = Ty->getTypeID() == Type::VectorTyID; +#endif + assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); + assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && + C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& "This is an illegal floating point truncation!"); return getFoldedCast(Instruction::FPTrunc, C, Ty); } Constant *ConstantExpr::getFPExtend(Constant *C, const Type *Ty) { - assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && - C->getType()->getPrimitiveSizeInBits() < Ty->getPrimitiveSizeInBits()&& +#ifndef NDEBUG + bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; + bool toVec = Ty->getTypeID() == Type::VectorTyID; +#endif + assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); + assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && + C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "This is an illegal floating point extension!"); return getFoldedCast(Instruction::FPExt, C, Ty); } Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Jun 15 17:12:54 2009 @@ -1837,11 +1837,11 @@ case Instruction::BitCast: return true; // BitCast never modifies bits. case Instruction::PtrToInt: - return IntPtrTy->getPrimitiveSizeInBits() == - getType()->getPrimitiveSizeInBits(); + return IntPtrTy->getScalarSizeInBits() == + getType()->getScalarSizeInBits(); case Instruction::IntToPtr: - return IntPtrTy->getPrimitiveSizeInBits() == - getOperand(0)->getType()->getPrimitiveSizeInBits(); + return IntPtrTy->getScalarSizeInBits() == + getOperand(0)->getType()->getScalarSizeInBits(); } } @@ -1946,8 +1946,8 @@ return 0; case 7: { // ptrtoint, inttoptr -> bitcast (ptr -> ptr) if int size is >= ptr size - unsigned PtrSize = IntPtrTy->getPrimitiveSizeInBits(); - unsigned MidSize = MidTy->getPrimitiveSizeInBits(); + unsigned PtrSize = IntPtrTy->getScalarSizeInBits(); + unsigned MidSize = MidTy->getScalarSizeInBits(); if (MidSize >= PtrSize) return Instruction::BitCast; return 0; @@ -1956,8 +1956,8 @@ // ext, trunc -> bitcast, if the SrcTy and DstTy are same size // ext, trunc -> ext, if sizeof(SrcTy) < sizeof(DstTy) // ext, trunc -> trunc, if sizeof(SrcTy) > sizeof(DstTy) - unsigned SrcSize = SrcTy->getPrimitiveSizeInBits(); - unsigned DstSize = DstTy->getPrimitiveSizeInBits(); + unsigned SrcSize = SrcTy->getScalarSizeInBits(); + unsigned DstSize = DstTy->getScalarSizeInBits(); if (SrcSize == DstSize) return Instruction::BitCast; else if (SrcSize < DstSize) @@ -1985,9 +1985,9 @@ return 0; case 13: { // inttoptr, ptrtoint -> bitcast if SrcSize<=PtrSize and SrcSize==DstSize - unsigned PtrSize = IntPtrTy->getPrimitiveSizeInBits(); - unsigned SrcSize = SrcTy->getPrimitiveSizeInBits(); - unsigned DstSize = DstTy->getPrimitiveSizeInBits(); + unsigned PtrSize = IntPtrTy->getScalarSizeInBits(); + unsigned SrcSize = SrcTy->getScalarSizeInBits(); + unsigned DstSize = DstTy->getScalarSizeInBits(); if (SrcSize <= PtrSize && SrcSize == DstSize) return Instruction::BitCast; return 0; @@ -2051,7 +2051,7 @@ CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore) { - if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) + if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); return Create(Instruction::ZExt, S, Ty, Name, InsertBefore); } @@ -2059,7 +2059,7 @@ CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { - if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) + if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); return Create(Instruction::ZExt, S, Ty, Name, InsertAtEnd); } @@ -2067,7 +2067,7 @@ CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore) { - if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) + if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); return Create(Instruction::SExt, S, Ty, Name, InsertBefore); } @@ -2075,7 +2075,7 @@ CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { - if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) + if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); return Create(Instruction::SExt, S, Ty, Name, InsertAtEnd); } @@ -2083,7 +2083,7 @@ CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty, const std::string &Name, Instruction *InsertBefore) { - if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) + if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) return Create(Instruction::BitCast, S, Ty, Name, InsertBefore); return Create(Instruction::Trunc, S, Ty, Name, InsertBefore); } @@ -2091,7 +2091,7 @@ CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { - if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits()) + if (S->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd); return Create(Instruction::Trunc, S, Ty, Name, InsertAtEnd); } @@ -2125,8 +2125,8 @@ bool isSigned, const std::string &Name, Instruction *InsertBefore) { assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast"); - unsigned SrcBits = C->getType()->getPrimitiveSizeInBits(); - unsigned DstBits = Ty->getPrimitiveSizeInBits(); + unsigned SrcBits = C->getType()->getScalarSizeInBits(); + unsigned DstBits = Ty->getScalarSizeInBits(); Instruction::CastOps opcode = (SrcBits == DstBits ? Instruction::BitCast : (SrcBits > DstBits ? Instruction::Trunc : @@ -2138,8 +2138,8 @@ bool isSigned, const std::string &Name, BasicBlock *InsertAtEnd) { assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast"); - unsigned SrcBits = C->getType()->getPrimitiveSizeInBits(); - unsigned DstBits = Ty->getPrimitiveSizeInBits(); + unsigned SrcBits = C->getType()->getScalarSizeInBits(); + unsigned DstBits = Ty->getScalarSizeInBits(); Instruction::CastOps opcode = (SrcBits == DstBits ? Instruction::BitCast : (SrcBits > DstBits ? Instruction::Trunc : @@ -2152,8 +2152,8 @@ Instruction *InsertBefore) { assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && "Invalid cast"); - unsigned SrcBits = C->getType()->getPrimitiveSizeInBits(); - unsigned DstBits = Ty->getPrimitiveSizeInBits(); + unsigned SrcBits = C->getType()->getScalarSizeInBits(); + unsigned DstBits = Ty->getScalarSizeInBits(); Instruction::CastOps opcode = (SrcBits == DstBits ? Instruction::BitCast : (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt)); @@ -2165,8 +2165,8 @@ BasicBlock *InsertAtEnd) { assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && "Invalid cast"); - unsigned SrcBits = C->getType()->getPrimitiveSizeInBits(); - unsigned DstBits = Ty->getPrimitiveSizeInBits(); + unsigned SrcBits = C->getType()->getScalarSizeInBits(); + unsigned DstBits = Ty->getScalarSizeInBits(); Instruction::CastOps opcode = (SrcBits == DstBits ? Instruction::BitCast : (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt)); @@ -2183,8 +2183,8 @@ return true; // Get the bit sizes, we'll need these - unsigned SrcBits = SrcTy->getPrimitiveSizeInBits(); // 0 for ptr/vector - unsigned DestBits = DestTy->getPrimitiveSizeInBits(); // 0 for ptr/vector + unsigned SrcBits = SrcTy->getScalarSizeInBits(); // 0 for ptr + unsigned DestBits = DestTy->getScalarSizeInBits(); // 0 for ptr // Run through the possibilities ... if (DestTy->isInteger()) { // Casting to integral @@ -2242,8 +2242,8 @@ const Value *Src, bool SrcIsSigned, const Type *DestTy, bool DestIsSigned) { // Get the bit sizes, we'll need these const Type *SrcTy = Src->getType(); - unsigned SrcBits = SrcTy->getPrimitiveSizeInBits(); // 0 for ptr/vector - unsigned DestBits = DestTy->getPrimitiveSizeInBits(); // 0 for ptr/vector + unsigned SrcBits = SrcTy->getScalarSizeInBits(); // 0 for ptr + unsigned DestBits = DestTy->getScalarSizeInBits(); // 0 for ptr assert(SrcTy->isFirstClassType() && DestTy->isFirstClassType() && "Only first class types are castable!"); @@ -2344,8 +2344,8 @@ return false; // Get the size of the types in bits, we'll need this later - unsigned SrcBitSize = SrcTy->getPrimitiveSizeInBits(); - unsigned DstBitSize = DstTy->getPrimitiveSizeInBits(); + unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); + unsigned DstBitSize = DstTy->getScalarSizeInBits(); // Switch on the opcode provided switch (op) { @@ -2400,7 +2400,7 @@ // Now we know we're not dealing with a pointer/non-pointer mismatch. In all // these cases, the cast is okay if the source and destination bit widths // are identical. - return SrcBitSize == DstBitSize; + return SrcTy->getPrimitiveSizeInBits() == DstTy->getPrimitiveSizeInBits(); } } Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Mon Jun 15 17:12:54 2009 @@ -112,6 +112,14 @@ return this; } +/// getScalarType - If this is a vector type, return the element type, +/// otherwise return this. +const Type *Type::getScalarType() const { + if (const VectorType *VTy = dyn_cast(this)) + return VTy->getElementType(); + return this; +} + /// isIntOrIntVector - Return true if this is an integer type or a vector of /// integer types. /// @@ -174,6 +182,28 @@ } } +/// getScalarSizeInBits - If this is a vector type, return the +/// getPrimitiveSizeInBits value for the element type. Otherwise return the +/// getPrimitiveSizeInBits value for this type. +unsigned Type::getScalarSizeInBits() const { + return getScalarType()->getPrimitiveSizeInBits(); +} + +/// getFPMantissaWidth - Return the width of the mantissa of this type. This +/// is only valid on floating point types. If the FP type does not +/// have a stable mantissa (e.g. ppc long double), this method returns -1. +int Type::getFPMantissaWidth() const { + if (const VectorType *VTy = dyn_cast(this)) + return VTy->getElementType()->getFPMantissaWidth(); + assert(isFloatingPoint() && "Not a floating point type!"); + if (ID == FloatTyID) return 24; + if (ID == DoubleTyID) return 53; + if (ID == X86_FP80TyID) return 64; + if (ID == FP128TyID) return 113; + assert(ID == PPC_FP128TyID && "unknown fp type"); + return -1; +} + /// isSizedDerivedType - Derived types like structures and arrays are sized /// iff all of the members of the type are sized as well. Since asking for /// their size is relatively uncommon, move this operation out of line. Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=73431&r1=73430&r2=73431&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Jun 15 17:12:54 2009 @@ -745,8 +745,8 @@ const Type *DestTy = I.getType(); // Get the size of the types in bits, we'll need this later - unsigned SrcBitSize = SrcTy->getPrimitiveSizeInBits(); - unsigned DestBitSize = DestTy->getPrimitiveSizeInBits(); + unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); + unsigned DestBitSize = DestTy->getScalarSizeInBits(); Assert1(SrcTy->isIntOrIntVector(), "Trunc only operates on integer", &I); Assert1(DestTy->isIntOrIntVector(), "Trunc only produces integer", &I); @@ -767,8 +767,8 @@ Assert1(DestTy->isIntOrIntVector(), "ZExt only produces an integer", &I); Assert1(isa(SrcTy) == isa(DestTy), "zext source and destination must both be a vector or neither", &I); - unsigned SrcBitSize = SrcTy->getPrimitiveSizeInBits(); - unsigned DestBitSize = DestTy->getPrimitiveSizeInBits(); + unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); + unsigned DestBitSize = DestTy->getScalarSizeInBits(); Assert1(SrcBitSize < DestBitSize,"Type too small for ZExt", &I); @@ -781,8 +781,8 @@ const Type *DestTy = I.getType(); // Get the size of the types in bits, we'll need this later - unsigned SrcBitSize = SrcTy->getPrimitiveSizeInBits(); - unsigned DestBitSize = DestTy->getPrimitiveSizeInBits(); + unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); + unsigned DestBitSize = DestTy->getScalarSizeInBits(); Assert1(SrcTy->isIntOrIntVector(), "SExt only operates on integer", &I); Assert1(DestTy->isIntOrIntVector(), "SExt only produces an integer", &I); @@ -798,8 +798,8 @@ const Type *SrcTy = I.getOperand(0)->getType(); const Type *DestTy = I.getType(); // Get the size of the types in bits, we'll need this later - unsigned SrcBitSize = SrcTy->getPrimitiveSizeInBits(); - unsigned DestBitSize = DestTy->getPrimitiveSizeInBits(); + unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); + unsigned DestBitSize = DestTy->getScalarSizeInBits(); Assert1(SrcTy->isFPOrFPVector(),"FPTrunc only operates on FP", &I); Assert1(DestTy->isFPOrFPVector(),"FPTrunc only produces an FP", &I); @@ -816,8 +816,8 @@ const Type *DestTy = I.getType(); // Get the size of the types in bits, we'll need this later - unsigned SrcBitSize = SrcTy->getPrimitiveSizeInBits(); - unsigned DestBitSize = DestTy->getPrimitiveSizeInBits(); + unsigned SrcBitSize = SrcTy->getScalarSizeInBits(); + unsigned DestBitSize = DestTy->getScalarSizeInBits(); Assert1(SrcTy->isFPOrFPVector(),"FPExt only operates on FP", &I); Assert1(DestTy->isFPOrFPVector(),"FPExt only produces an FP", &I); Added: llvm/trunk/test/Feature/vector-cast-constant-exprs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/vector-cast-constant-exprs.ll?rev=73431&view=auto ============================================================================== --- llvm/trunk/test/Feature/vector-cast-constant-exprs.ll (added) +++ llvm/trunk/test/Feature/vector-cast-constant-exprs.ll Mon Jun 15 17:12:54 2009 @@ -0,0 +1,37 @@ +; RUN: llvm-as < %s | llvm-dis | not grep {ret.*(} + +; All of these constant expressions should fold. + +define <2 x float> @ga() { + ret <2 x float> fptrunc (<2 x double> to <2 x float>) +} +define <2 x double> @gb() { + ret <2 x double> fpext (<2 x float> to <2 x double>) +} +define <2 x i64> @gd() { + ret <2 x i64> zext (<2 x i32> to <2 x i64>) +} +define <2 x i64> @ge() { + ret <2 x i64> sext (<2 x i32> to <2 x i64>) +} +define <2 x i32> @gf() { + ret <2 x i32> trunc (<2 x i64> to <2 x i32>) +} +define <2 x i32> @gh() { + ret <2 x i32> fptoui (<2 x float> to <2 x i32>) +} +define <2 x i32> @gi() { + ret <2 x i32> fptosi (<2 x float> to <2 x i32>) +} +define <2 x float> @gj() { + ret <2 x float> uitofp (<2 x i32> to <2 x float>) +} +define <2 x float> @gk() { + ret <2 x float> sitofp (<2 x i32> to <2 x float>) +} +define <2 x double> @gl() { + ret <2 x double> bitcast (<2 x double> to <2 x double>) +} +define <2 x double> @gm() { + ret <2 x double> bitcast (<2 x i64> to <2 x double>) +} Added: llvm/trunk/test/Transforms/InstCombine/vector-casts.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vector-casts.ll?rev=73431&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/vector-casts.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/vector-casts.ll Mon Jun 15 17:12:54 2009 @@ -0,0 +1,55 @@ +; RUN: llvm-as < %s | opt -instcombine + +define void @convert(<2 x i32>* %dst.addr, <2 x i64> %src) nounwind { +entry: + %val = trunc <2 x i64> %src to <2 x i32> ; <<2 x i32>> [#uses=1] + %add = add <2 x i32> %val, ; <<2 x i32>> [#uses=1] + store <2 x i32> %add, <2 x i32>* %dst.addr + ret void +} + +define <2 x i65> @foo(<2 x i64> %t) { + %a = trunc <2 x i64> %t to <2 x i32> + %b = zext <2 x i32> %a to <2 x i65> + ret <2 x i65> %b +} +define <2 x i64> @bar(<2 x i65> %t) { + %a = trunc <2 x i65> %t to <2 x i32> + %b = zext <2 x i32> %a to <2 x i64> + ret <2 x i64> %b +} +define <2 x i65> @foos(<2 x i64> %t) { + %a = trunc <2 x i64> %t to <2 x i32> + %b = sext <2 x i32> %a to <2 x i65> + ret <2 x i65> %b +} +define <2 x i64> @bars(<2 x i65> %t) { + %a = trunc <2 x i65> %t to <2 x i32> + %b = sext <2 x i32> %a to <2 x i64> + ret <2 x i64> %b +} +define <2 x i64> @quxs(<2 x i64> %t) { + %a = trunc <2 x i64> %t to <2 x i32> + %b = sext <2 x i32> %a to <2 x i64> + ret <2 x i64> %b +} +define <2 x i64> @quxt(<2 x i64> %t) { + %a = shl <2 x i64> %t, + %b = ashr <2 x i64> %a, + ret <2 x i64> %b +} +define <2 x double> @fa(<2 x double> %t) { + %a = fptrunc <2 x double> %t to <2 x float> + %b = fpext <2 x float> %a to <2 x double> + ret <2 x double> %b +} +define <2 x double> @fb(<2 x double> %t) { + %a = fptoui <2 x double> %t to <2 x i64> + %b = uitofp <2 x i64> %a to <2 x double> + ret <2 x double> %b +} +define <2 x double> @fc(<2 x double> %t) { + %a = fptosi <2 x double> %t to <2 x i64> + %b = sitofp <2 x i64> %a to <2 x double> + ret <2 x double> %b +} From gohman at apple.com Mon Jun 15 17:25:13 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 22:25:13 -0000 Subject: [llvm-commits] [llvm] r73433 - in /llvm/trunk/lib/VMCore: Constants.cpp Instructions.cpp Message-ID: <200906152225.n5FMPDU3011064@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 17:25:12 2009 New Revision: 73433 URL: http://llvm.org/viewvc/llvm-project?rev=73433&view=rev Log: Use Type::isIntOrIntVector and Type::isFPOrFPVector. Modified: llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Instructions.cpp Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73433&r1=73432&r2=73433&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Mon Jun 15 17:25:12 2009 @@ -2246,34 +2246,30 @@ case Instruction::UDiv: case Instruction::SDiv: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert((C1->getType()->isInteger() || (isa(C1->getType()) && - cast(C1->getType())->getElementType()->isInteger())) && + assert(C1->getType()->isIntOrIntVector() && "Tried to create an arithmetic operation on a non-arithmetic type!"); break; case Instruction::FDiv: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert((C1->getType()->isFloatingPoint() || (isa(C1->getType()) - && cast(C1->getType())->getElementType()->isFloatingPoint())) - && "Tried to create an arithmetic operation on a non-arithmetic type!"); + assert(C1->getType()->isFPOrFPVector() && + "Tried to create an arithmetic operation on a non-arithmetic type!"); break; case Instruction::URem: case Instruction::SRem: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert((C1->getType()->isInteger() || (isa(C1->getType()) && - cast(C1->getType())->getElementType()->isInteger())) && + assert(C1->getType()->isIntOrIntVector() && "Tried to create an arithmetic operation on a non-arithmetic type!"); break; case Instruction::FRem: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert((C1->getType()->isFloatingPoint() || (isa(C1->getType()) - && cast(C1->getType())->getElementType()->isFloatingPoint())) - && "Tried to create an arithmetic operation on a non-arithmetic type!"); + assert(C1->getType()->isFPOrFPVector() && + "Tried to create an arithmetic operation on a non-arithmetic type!"); break; case Instruction::And: case Instruction::Or: case Instruction::Xor: assert(C1->getType() == C2->getType() && "Op types should be identical!"); - assert((C1->getType()->isInteger() || isa(C1->getType())) && + assert(C1->getType()->isIntOrIntVector() && "Tried to create a logical operation on a non-integral type!"); break; case Instruction::Shl: Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=73433&r1=73432&r2=73433&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Jun 15 17:25:12 2009 @@ -1576,9 +1576,8 @@ case FDiv: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert((getType()->isFloatingPoint() || (isa(getType()) && - cast(getType())->getElementType()->isFloatingPoint())) - && "Incorrect operand type (not floating point) for FDIV"); + assert(getType()->isFPOrFPVector() && + "Incorrect operand type (not floating point) for FDIV"); break; case URem: case SRem: @@ -1591,9 +1590,8 @@ case FRem: assert(getType() == LHS->getType() && "Arithmetic operation should return same type as operands!"); - assert((getType()->isFloatingPoint() || (isa(getType()) && - cast(getType())->getElementType()->isFloatingPoint())) - && "Incorrect operand type (not floating point) for FREM"); + assert(getType()->isFPOrFPVector() && + "Incorrect operand type (not floating point) for FREM"); break; case Shl: case LShr: @@ -2137,7 +2135,8 @@ CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty, bool isSigned, const std::string &Name, BasicBlock *InsertAtEnd) { - assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast"); + assert(C->getType()->isIntOrIntVector() && Ty->isIntOrIntVector() && + "Invalid cast"); unsigned SrcBits = C->getType()->getScalarSizeInBits(); unsigned DstBits = Ty->getScalarSizeInBits(); Instruction::CastOps opcode = @@ -2150,7 +2149,7 @@ CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty, const std::string &Name, Instruction *InsertBefore) { - assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && + assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && "Invalid cast"); unsigned SrcBits = C->getType()->getScalarSizeInBits(); unsigned DstBits = Ty->getScalarSizeInBits(); @@ -2163,7 +2162,7 @@ CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd) { - assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && + assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && "Invalid cast"); unsigned SrcBits = C->getType()->getScalarSizeInBits(); unsigned DstBits = Ty->getScalarSizeInBits(); From evan.cheng at apple.com Mon Jun 15 17:32:01 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 15 Jun 2009 22:32:01 -0000 Subject: [llvm-commits] [llvm] r73434 - /llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Message-ID: <200906152232.n5FMW1GW011309@zion.cs.uiuc.edu> Author: evancheng Date: Mon Jun 15 17:32:01 2009 New Revision: 73434 URL: http://llvm.org/viewvc/llvm-project?rev=73434&view=rev Log: On Darwin, frame pointer r7 is never available. Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp?rev=73434&r1=73433&r2=73434&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Mon Jun 15 17:32:01 2009 @@ -385,7 +385,7 @@ if (Hint.first == ARMRI::RegPairEven) { - if (!hasFP(MF)) { + if (!STI.isTargetDarwin() && !hasFP(MF)) { if (!STI.isR9Reserved()) return std::make_pair(GPREven1, GPREven1 + (sizeof(GPREven1)/sizeof(unsigned))); @@ -408,7 +408,7 @@ GPREven6 + (sizeof(GPREven6)/sizeof(unsigned))); } } else if (Hint.first == ARMRI::RegPairOdd) { - if (!hasFP(MF)) { + if (!STI.isTargetDarwin() && !hasFP(MF)) { if (!STI.isR9Reserved()) return std::make_pair(GPROdd1, GPROdd1 + (sizeof(GPROdd1)/sizeof(unsigned))); From gohman at apple.com Mon Jun 15 17:32:41 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 22:32:41 -0000 Subject: [llvm-commits] [llvm] r73435 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Message-ID: <200906152232.n5FMWfEi011341@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 17:32:41 2009 New Revision: 73435 URL: http://llvm.org/viewvc/llvm-project?rev=73435&view=rev Log: Change this from an assert to a cerr+exit, since it's diagnosing an unsupported inline asm construct, rather than verifying a code invariant. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=73435&r1=73434&r2=73435&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon Jun 15 17:32:41 2009 @@ -5317,8 +5317,12 @@ if ((OpFlag & 7) == 2 /*REGDEF*/ || (OpFlag & 7) == 6 /* EARLYCLOBBER REGDEF */) { // Add (OpFlag&0xffff)>>3 registers to MatchedRegs. - assert(!OpInfo.isIndirect && - "Don't know how to handle tied indirect register inputs yet!"); + if (OpInfo.isIndirect) { + cerr << "llvm: error: " + "Don't know how to handle tied indirect " + "register inputs yet!\n"; + exit(1); + } RegsForValue MatchedRegs; MatchedRegs.TLI = &TLI; MatchedRegs.ValueVTs.push_back(InOperandVal.getValueType()); From gohman at apple.com Mon Jun 15 17:34:25 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 15:34:25 -0700 Subject: [llvm-commits] [llvm] r71757 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp In-Reply-To: <27A5F96D-AE57-4471-B717-DDE6FBA1BB2F@apple.com> References: <200905140030.n4E0UJ3H020876@zion.cs.uiuc.edu> <95C426D7-58A9-4A1A-B276-40C8FEB9C03D@apple.com> <27A5F96D-AE57-4471-B717-DDE6FBA1BB2F@apple.com> Message-ID: <067E394A-CA56-48C4-9BAE-668E771C7192@apple.com> On Jun 14, 2009, at 10:55 PM, Chris Lattner wrote: > > On May 18, 2009, at 12:02 PM, Dan Gohman wrote: > > >> >> >> On May 13, 2009, at 6:38 PM, Chris Lattner wrote: >> >> >> >>> >>> >>> On May 13, 2009, at 5:30 PM, Dan Gohman wrote: >>> >>> >>> >>>> Author: djg >>>> >>>> Date: Wed May 13 19:30:16 2009 >>>> >>>> New Revision: 71757 >>>> >>>> >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=71757&view=rev >>>> >>>> Log: >>>> >>>> Add an assert to turn a segfault on an unsupported inline >>>> >>>> asm construct into an assertion failure. >>>> >>> >>> >>> Should this use printf+exit(1)? >>> >> >> >> >> >> I don't know. I was just following similar code elsewhere in >> >> the same file. Is there a conscious decision to use printf+exit >> >> for certain cases now? >> > > We should use printf+exit in the code generator for cases where user > code written in C can trigger the problem. assert should only be > used for things we know cannot happen due to invariants in the code > generator. Using "exit" makes it easier to find these places in the > future if we ever get a real error reporting mechanism. Ok, this code uses cerr+exit now. Dan From devang.patel at gmail.com Mon Jun 15 17:40:07 2009 From: devang.patel at gmail.com (Devang Patel) Date: Mon, 15 Jun 2009 15:40:07 -0700 Subject: [llvm-commits] [llvm] r73338 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/IPO.h lib/Transforms/IPO/PartialInlining.cpp In-Reply-To: <200906140826.n5E8QnKY026439@zion.cs.uiuc.edu> References: <200906140826.n5E8QnKY026439@zion.cs.uiuc.edu> Message-ID: <352a1fb20906151540j10173023wee929b26e19f9927@mail.gmail.com> Hi Owen, Is there any reason to not walk call graph? On Sun, Jun 14, 2009 at 1:26 AM, Owen Anderson wrote: > Author: resistor > Date: Sun Jun 14 03:26:32 2009 > New Revision: 73338 > > URL: http://llvm.org/viewvc/llvm-project?rev=73338&view=rev > Log: > Add an early implementation of a partial inlining pass. The idea behind this > is that, for functions whose bodies are entirely guarded by an if-statement, it > can be profitable to pull the test out of the callee and into the caller. > > This code has had some cursory testing, but still has a number of known issues > on the LLVM test suite. Make sure it handles recursive functions properly :) > + ?// Inline the top-level if test into all callers. > + ?std::vector Users(duplicateFunction->use_begin(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? duplicateFunction->use_end()); > + ?for (std::vector::iterator UI = Users.begin(), UE = Users.end(); > + ? ? ? UI != UE; ++UI) > + ? ?if (CallInst* CI = dyn_cast(*UI)) > + ? ? ?InlineFunction(CI); > + ? ?else if (InvokeInst* II = dyn_cast(*UI)) > + ? ? ?InlineFunction(II); > + What if InlineFunction() does not inline the call/invoke ? > + ?// Ditch the duplicate, since we're done with it, and rewrite all remaining > + ?// users (function pointers, etc.) back to the original function. > + ?duplicateFunction->replaceAllUsesWith(F); > + ?duplicateFunction->eraseFromParent(); > + - Devang From gohman at apple.com Mon Jun 15 17:49:35 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 22:49:35 -0000 Subject: [llvm-commits] [llvm] r73436 - /llvm/trunk/test/CodeGen/X86/fmul-zero.ll Message-ID: <200906152249.n5FMnZ4F011888@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 17:49:34 2009 New Revision: 73436 URL: http://llvm.org/viewvc/llvm-project?rev=73436&view=rev Log: Update this test to use fmul instead of mul. Modified: llvm/trunk/test/CodeGen/X86/fmul-zero.ll Modified: llvm/trunk/test/CodeGen/X86/fmul-zero.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fmul-zero.ll?rev=73436&r1=73435&r2=73436&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fmul-zero.ll (original) +++ llvm/trunk/test/CodeGen/X86/fmul-zero.ll Mon Jun 15 17:49:34 2009 @@ -3,7 +3,7 @@ define void @test14(<4 x float>*) nounwind { load <4 x float>* %0, align 1 - mul <4 x float> %2, zeroinitializer + fmul <4 x float> %2, zeroinitializer store <4 x float> %3, <4 x float>* %0, align 1 ret void } From gohman at apple.com Mon Jun 15 17:50:40 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 22:50:40 -0000 Subject: [llvm-commits] [llvm] r73437 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200906152250.n5FMoegN011932@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 17:50:40 2009 New Revision: 73437 URL: http://llvm.org/viewvc/llvm-project?rev=73437&view=rev Log: Add a CreateFNeg function to IRBuilder. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=73437&r1=73436&r2=73437&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Mon Jun 15 17:50:40 2009 @@ -291,6 +291,11 @@ return Folder.CreateNeg(VC); return Insert(BinaryOperator::CreateNeg(V), Name); } + Value *CreateFNeg(Value *V, const char *Name = "") { + if (Constant *VC = dyn_cast(V)) + return Folder.CreateFNeg(VC); + return Insert(BinaryOperator::CreateFNeg(V), Name); + } Value *CreateNot(Value *V, const char *Name = "") { if (Constant *VC = dyn_cast(V)) return Folder.CreateNot(VC); From resistor at mac.com Mon Jun 15 17:54:48 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 15 Jun 2009 22:54:48 -0000 Subject: [llvm-commits] [llvm] r73438 - in /llvm/trunk: include/llvm/ADT/PostOrderIterator.h lib/CodeGen/LazyLiveness.cpp Message-ID: <200906152254.n5FMsmsZ012059@zion.cs.uiuc.edu> Author: resistor Date: Mon Jun 15 17:54:48 2009 New Revision: 73438 URL: http://llvm.org/viewvc/llvm-project?rev=73438&view=rev Log: Owen Anderson 2009-06-15: Use a SmallPtrSet here, for speed and to match df_iterator. Owen Anderson 2009-06-15: Remember to clear out our maps to prevent crashing. Modified: llvm/trunk/include/llvm/ADT/PostOrderIterator.h llvm/trunk/lib/CodeGen/LazyLiveness.cpp Modified: llvm/trunk/include/llvm/ADT/PostOrderIterator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PostOrderIterator.h?rev=73438&r1=73437&r2=73438&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/PostOrderIterator.h (original) +++ llvm/trunk/include/llvm/ADT/PostOrderIterator.h Mon Jun 15 17:54:48 2009 @@ -18,6 +18,7 @@ #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/iterator.h" +#include "llvm/ADT/SmallPtrSet.h" #include #include #include @@ -39,9 +40,9 @@ }; template::NodeType*>, - bool ExtStorage = false, - class GT = GraphTraits > + class SetType = llvm::SmallPtrSet::NodeType*, 8>, + bool ExtStorage = false, + class GT = GraphTraits > class po_iterator : public forward_iterator, public po_iterator_storage { typedef forward_iterator super; Modified: llvm/trunk/lib/CodeGen/LazyLiveness.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LazyLiveness.cpp?rev=73438&r1=73437&r2=73438&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LazyLiveness.cpp (original) +++ llvm/trunk/lib/CodeGen/LazyLiveness.cpp Mon Jun 15 17:54:48 2009 @@ -32,10 +32,12 @@ calculated.set(preorder[MBB]); for (SparseBitVector<128>::iterator I = tmp.begin(); I != tmp.end(); ++I) { + assert(rev_preorder.size() > *I && "Unknown block!"); + MachineBasicBlock* SrcMBB = rev_preorder[*I]; - for (MachineBasicBlock::succ_iterator SI = SrcMBB->succ_begin(); - SI != SrcMBB->succ_end(); ++SI) { + for (MachineBasicBlock::succ_iterator SI = SrcMBB->succ_begin(), + SE = SrcMBB->succ_end(); SI != SE; ++SI) { MachineBasicBlock* TgtMBB = *SI; if (backedges.count(std::make_pair(SrcMBB, TgtMBB)) && @@ -44,7 +46,8 @@ computeBackedgeChain(mf, TgtMBB); tv[MBB].set(preorder[TgtMBB]); - tv[MBB] |= tv[TgtMBB]; + SparseBitVector<128> right = tv[TgtMBB]; + tv[MBB] |= right; } } @@ -60,6 +63,12 @@ backedge_target.clear(); calculated.clear(); preorder.clear(); + rev_preorder.clear(); + + rv.resize(mf.size()); + tv.resize(mf.size()); + preorder.resize(mf.size()); + rev_preorder.reserve(mf.size()); MRI = &mf.getRegInfo(); MachineDominatorTree& MDT = getAnalysis(); @@ -106,8 +115,8 @@ for (MachineBasicBlock::succ_iterator SI = (*POI)->succ_begin(), SE = (*POI)->succ_end(); SI != SE; ++SI) if (!backedges.count(std::make_pair(*POI, *SI)) && tv.count(*SI)) { - SparseBitVector<128>& PBV = tv[*POI]; - PBV = tv[*SI]; + SparseBitVector<128> right = tv[*SI]; + tv[*POI] |= right; } for (po_iterator POI = po_begin(&*mf.begin()), From gohman at apple.com Mon Jun 15 18:00:22 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 16:00:22 -0700 Subject: [llvm-commits] [llvm] r73412 - in /llvm/trunk: ./ lib/Transforms/IPO/PartialInlining.cpp In-Reply-To: <200906152050.n5FKoR58007658@zion.cs.uiuc.edu> References: <200906152050.n5FKoR58007658@zion.cs.uiuc.edu> Message-ID: <451A742D-2F74-4554-92AE-CBE0A70C892B@apple.com> On Jun 15, 2009, at 1:50 PM, Owen Anderson wrote: > Author: resistor > Date: Mon Jun 15 15:50:26 2009 > New Revision: 73412 > > URL: http://llvm.org/viewvc/llvm-project?rev=73412&view=rev > Log: > Merge PartialInliner changes. > > Modified: > llvm/trunk/ (props changed) > llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp > > Propchange: llvm/trunk/ > > ------------------------------------------------------------------------------ > bzr:see-revprops = 73412 Hi Owen, It appears this commit contained a bzr-specific property change. Dan From gohman at apple.com Mon Jun 15 18:05:57 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 23:05:57 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73439 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200906152305.n5FN5w97012380@zion.cs.uiuc.edu> Author: djg Date: Mon Jun 15 18:05:57 2009 New Revision: 73439 URL: http://llvm.org/viewvc/llvm-project?rev=73439&view=rev Log: Update for the recent API changes in which floating-point arithmetic operations were split out to use separate opcodes from integer arithmetic operations. 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=73439&r1=73438&r2=73439&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Jun 15 18:05:57 2009 @@ -862,9 +862,24 @@ case UNGE_EXPR: Result = EmitCompare(exp, 0, 0, FCmpInst::FCMP_UGE); break; case UNEQ_EXPR: Result = EmitCompare(exp, 0, 0, FCmpInst::FCMP_UEQ); break; case LTGT_EXPR: Result = EmitCompare(exp, 0, 0, FCmpInst::FCMP_ONE); break; - case PLUS_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Add);break; - case MINUS_EXPR:Result = EmitBinOp(exp, DestLoc, Instruction::Sub);break; - case MULT_EXPR: Result = EmitBinOp(exp, DestLoc, Instruction::Mul);break; + case PLUS_EXPR: + Result = EmitBinOp(exp, DestLoc, + FLOAT_TYPE_P(TREE_TYPE(exp)) ? + Instruction::FAdd : + Instruction::Add); + break; + case MINUS_EXPR: + Result = EmitBinOp(exp, DestLoc, + FLOAT_TYPE_P(TREE_TYPE(exp)) ? + Instruction::FSub : + Instruction::Sub); + break; + case MULT_EXPR: + Result = EmitBinOp(exp, DestLoc, + FLOAT_TYPE_P(TREE_TYPE(exp)) ? + Instruction::FMul : + Instruction::Mul); + break; case EXACT_DIV_EXPR: Result = EmitEXACT_DIV_EXPR(exp, DestLoc); break; case TRUNC_DIV_EXPR: if (TYPE_UNSIGNED(TREE_TYPE(exp))) @@ -3089,6 +3104,8 @@ Value *TreeToLLVM::EmitNEGATE_EXPR(tree exp, const MemRef *DestLoc) { if (!DestLoc) { Value *V = Emit(TREE_OPERAND(exp, 0), 0); + if (V->getType()->isFPOrFPVector()) + return Builder.CreateFNeg(V); if (!isa(V->getType())) return Builder.CreateNeg(V); @@ -3108,8 +3125,8 @@ // Handle complex numbers: -(a+ib) = -a + i*-b Value *R, *I; EmitLoadFromComplex(R, I, Tmp); - R = Builder.CreateNeg(R); - I = Builder.CreateNeg(I); + R = Builder.CreateFNeg(R); + I = Builder.CreateFNeg(I); EmitStoreToComplex(*DestLoc, R, I); return 0; } @@ -3125,7 +3142,7 @@ // Handle complex numbers: ~(a+ib) = a + i*-b Value *R, *I; EmitLoadFromComplex(R, I, Tmp); - I = Builder.CreateNeg(I); + I = Builder.CreateFNeg(I); EmitStoreToComplex(*DestLoc, R, I); return 0; } @@ -5776,37 +5793,37 @@ switch (TREE_CODE(exp)) { default: TODO(exp); case PLUS_EXPR: // (a+ib) + (c+id) = (a+c) + i(b+d) - DSTr = Builder.CreateAdd(LHSr, RHSr, "tmpr"); - DSTi = Builder.CreateAdd(LHSi, RHSi, "tmpi"); + DSTr = Builder.CreateFAdd(LHSr, RHSr, "tmpr"); + DSTi = Builder.CreateFAdd(LHSi, RHSi, "tmpi"); break; case MINUS_EXPR: // (a+ib) - (c+id) = (a-c) + i(b-d) - DSTr = Builder.CreateSub(LHSr, RHSr, "tmpr"); - DSTi = Builder.CreateSub(LHSi, RHSi, "tmpi"); + DSTr = Builder.CreateFSub(LHSr, RHSr, "tmpr"); + DSTi = Builder.CreateFSub(LHSi, RHSi, "tmpi"); break; case MULT_EXPR: { // (a+ib) * (c+id) = (ac-bd) + i(ad+cb) - Value *Tmp1 = Builder.CreateMul(LHSr, RHSr); // a*c - Value *Tmp2 = Builder.CreateMul(LHSi, RHSi); // b*d - DSTr = Builder.CreateSub(Tmp1, Tmp2); // ac-bd - - Value *Tmp3 = Builder.CreateMul(LHSr, RHSi); // a*d - Value *Tmp4 = Builder.CreateMul(RHSr, LHSi); // c*b - DSTi = Builder.CreateAdd(Tmp3, Tmp4); // ad+cb + Value *Tmp1 = Builder.CreateFMul(LHSr, RHSr); // a*c + Value *Tmp2 = Builder.CreateFMul(LHSi, RHSi); // b*d + DSTr = Builder.CreateFSub(Tmp1, Tmp2); // ac-bd + + Value *Tmp3 = Builder.CreateFMul(LHSr, RHSi); // a*d + Value *Tmp4 = Builder.CreateFMul(RHSr, LHSi); // c*b + DSTi = Builder.CreateFAdd(Tmp3, Tmp4); // ad+cb break; } case RDIV_EXPR: { // (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd)) - Value *Tmp1 = Builder.CreateMul(LHSr, RHSr); // a*c - Value *Tmp2 = Builder.CreateMul(LHSi, RHSi); // b*d - Value *Tmp3 = Builder.CreateAdd(Tmp1, Tmp2); // ac+bd - - Value *Tmp4 = Builder.CreateMul(RHSr, RHSr); // c*c - Value *Tmp5 = Builder.CreateMul(RHSi, RHSi); // d*d - Value *Tmp6 = Builder.CreateAdd(Tmp4, Tmp5); // cc+dd + Value *Tmp1 = Builder.CreateFMul(LHSr, RHSr); // a*c + Value *Tmp2 = Builder.CreateFMul(LHSi, RHSi); // b*d + Value *Tmp3 = Builder.CreateFAdd(Tmp1, Tmp2); // ac+bd + + Value *Tmp4 = Builder.CreateFMul(RHSr, RHSr); // c*c + Value *Tmp5 = Builder.CreateFMul(RHSi, RHSi); // d*d + Value *Tmp6 = Builder.CreateFAdd(Tmp4, Tmp5); // cc+dd // FIXME: What about integer complex? DSTr = Builder.CreateFDiv(Tmp3, Tmp6); - Value *Tmp7 = Builder.CreateMul(LHSi, RHSr); // b*c - Value *Tmp8 = Builder.CreateMul(LHSr, RHSi); // a*d - Value *Tmp9 = Builder.CreateSub(Tmp7, Tmp8); // bc-ad + Value *Tmp7 = Builder.CreateFMul(LHSi, RHSr); // b*c + Value *Tmp8 = Builder.CreateFMul(LHSr, RHSi); // a*d + Value *Tmp9 = Builder.CreateFSub(Tmp7, Tmp8); // bc-ad DSTi = Builder.CreateFDiv(Tmp9, Tmp6); break; } From resistor at mac.com Mon Jun 15 18:12:00 2009 From: resistor at mac.com (Owen Anderson) Date: Mon, 15 Jun 2009 23:12:00 -0000 Subject: [llvm-commits] [llvm] r73441 - /llvm/trunk/ Message-ID: <200906152312.n5FNC0eS012583@zion.cs.uiuc.edu> Author: resistor Date: Mon Jun 15 18:12:00 2009 New Revision: 73441 URL: http://llvm.org/viewvc/llvm-project?rev=73441&view=rev Log: Remove extraneous propset. Modified: llvm/trunk/ (props changed) Propchange: llvm/trunk/ ------------------------------------------------------------------------------ --- bzr:see-revprops (original) +++ bzr:see-revprops (removed) @@ -1 +0,0 @@ -73412 From clattner at apple.com Mon Jun 15 18:13:59 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 15 Jun 2009 16:13:59 -0700 Subject: [llvm-commits] [llvm] r73431 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ lib/Analysis/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/VMCore/ test/Feature/ test/Transforms/InstCombine/ In-Reply-To: <200906152212.n5FMCuvr010609@zion.cs.uiuc.edu> References: <200906152212.n5FMCuvr010609@zion.cs.uiuc.edu> Message-ID: <614E1E90-F8B1-40AA-86A2-101434BE1E77@apple.com> On Jun 15, 2009, at 3:12 PM, Dan Gohman wrote: > Author: djg > Date: Mon Jun 15 17:12:54 2009 > New Revision: 73431 > > URL: http://llvm.org/viewvc/llvm-project?rev=73431&view=rev > Log: > Support vector casts in more places, fixing a variety of assertion > failures. > > To support this, add some utility functions to Type to help support > vector/scalar-independent code. Change ConstantInt::get and > ConstantFP::get to support vector types, and add an overload to > ConstantInt::get that uses a static IntegerType type, for > convenience. Hi Dan, Why should ConstantInt/FP::get allow a vector operand? It seems very strange to me to allow this. In general, please split up logically distinct changes into different pieces, it would be nice to have the core IR changes separately from the SCEV changes, -Chris From clattner at apple.com Mon Jun 15 18:14:29 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 15 Jun 2009 16:14:29 -0700 Subject: [llvm-commits] [llvm] r71757 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp In-Reply-To: <067E394A-CA56-48C4-9BAE-668E771C7192@apple.com> References: <200905140030.n4E0UJ3H020876@zion.cs.uiuc.edu> <95C426D7-58A9-4A1A-B276-40C8FEB9C03D@apple.com> <27A5F96D-AE57-4471-B717-DDE6FBA1BB2F@apple.com> <067E394A-CA56-48C4-9BAE-668E771C7192@apple.com> Message-ID: <80A29347-B802-4318-9E22-19226AE639C9@apple.com> On Jun 15, 2009, at 3:34 PM, Dan Gohman wrote: >>> >>> I don't know. I was just following similar code elsewhere in >>> >>> the same file. Is there a conscious decision to use printf+exit >>> >>> for certain cases now? >>> >> >> We should use printf+exit in the code generator for cases where >> user code written in C can trigger the problem. assert should only >> be used for things we know cannot happen due to invariants in the >> code generator. Using "exit" makes it easier to find these places >> in the future if we ever get a real error reporting mechanism. > > Ok, this code uses cerr+exit now. Thanks! -Chris From gohman at apple.com Mon Jun 15 18:33:28 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 15 Jun 2009 16:33:28 -0700 Subject: [llvm-commits] [llvm] r73431 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ lib/Analysis/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/VMCore/ test/Feature/ test/Transforms/InstCombine/ In-Reply-To: <614E1E90-F8B1-40AA-86A2-101434BE1E77@apple.com> References: <200906152212.n5FMCuvr010609@zion.cs.uiuc.edu> <614E1E90-F8B1-40AA-86A2-101434BE1E77@apple.com> Message-ID: <9ED72EF9-444F-4AEF-A7C6-8DC507F4CAD2@apple.com> On Jun 15, 2009, at 4:13 PM, Chris Lattner wrote: > > On Jun 15, 2009, at 3:12 PM, Dan Gohman wrote: > > >> Author: djg >> >> Date: Mon Jun 15 17:12:54 2009 >> >> New Revision: 73431 >> >> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=73431&view=rev >> >> Log: >> >> Support vector casts in more places, fixing a variety of assertion >> >> failures. >> >> >> >> To support this, add some utility functions to Type to help support >> >> vector/scalar-independent code. Change ConstantInt::get and >> >> ConstantFP::get to support vector types, and add an overload to >> >> ConstantInt::get that uses a static IntegerType type, for >> >> convenience. >> > > Hi Dan, > > Why should ConstantInt/FP::get allow a vector operand? It seems very > strange to me to allow this. It's a convenience for code that handles both vector and scalar values. In the same sense that the vector form of an add is an add that applies to each element of a vector, the vector form of a constant is a constant vector with each element equal to the constant. > In general, please split up logically distinct changes into different > pieces, it would be nice to have the core IR changes separately from > the SCEV changes, The SCEV changes here were needed in order to conform to the core IR API changes. Dan From clattner at apple.com Mon Jun 15 18:57:58 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 15 Jun 2009 16:57:58 -0700 Subject: [llvm-commits] [llvm] r73431 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ lib/Analysis/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/VMCore/ test/Feature/ test/Transforms/InstCombine/ In-Reply-To: <9ED72EF9-444F-4AEF-A7C6-8DC507F4CAD2@apple.com> References: <200906152212.n5FMCuvr010609@zion.cs.uiuc.edu> <614E1E90-F8B1-40AA-86A2-101434BE1E77@apple.com> <9ED72EF9-444F-4AEF-A7C6-8DC507F4CAD2@apple.com> Message-ID: <46812640-6BBE-441A-A4A8-9891E8CBAB16@apple.com> On Jun 15, 2009, at 4:33 PM, Dan Gohman wrote: >> Hi Dan, >> >> Why should ConstantInt/FP::get allow a vector operand? It seems very >> strange to me to allow this. > > It's a convenience for code that handles both vector and scalar > values. In the same sense that the vector form of an add is an > add that applies to each element of a vector, the vector form > of a constant is a constant vector with each element equal to > the constant. The part that confuses me is that code should generally know when it is working on a vector or not. Is ConstantInt::get(4, ) better than ConstantVector::get(4, ) ? >> In general, please split up logically distinct changes into different >> pieces, it would be nice to have the core IR changes separately from >> the SCEV changes, > > The SCEV changes here were needed in order to conform to > the core IR API changes. Ok, but couldn't the API changes go in first? -Chris From foldr at codedgers.com Mon Jun 15 19:13:52 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 16 Jun 2009 00:13:52 -0000 Subject: [llvm-commits] [llvm] r73448 - in /llvm/trunk/tools/llvmc/doc: LLVMC-Reference.rst LLVMC-Tutorial.rst Message-ID: <200906160013.n5G0DqJv014780@zion.cs.uiuc.edu> Author: foldr Date: Mon Jun 15 19:13:52 2009 New Revision: 73448 URL: http://llvm.org/viewvc/llvm-project?rev=73448&view=rev Log: Documentation update. Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst llvm/trunk/tools/llvmc/doc/LLVMC-Tutorial.rst Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst?rev=73448&r1=73447&r2=73448&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst (original) +++ llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Mon Jun 15 19:13:52 2009 @@ -94,9 +94,9 @@ * ``--check-graph`` - Check the compilation for common errors like mismatched output/input language names, multiple default edges and cycles. Because of - plugins, these checks can't be performed at compile-time. Exit with code zero if - no errors were found, and return the number of found errors otherwise. Hidden - option, useful for debugging LLVMC plugins. + plugins, these checks can't be performed at compile-time. Exit with code zero + if no errors were found, and return the number of found errors + otherwise. Hidden option, useful for debugging LLVMC plugins. * ``--view-graph`` - Show a graphical representation of the compilation graph and exit. Requires that you have ``dot`` and ``gv`` programs installed. Hidden @@ -104,8 +104,9 @@ * ``--write-graph`` - Write a ``compilation-graph.dot`` file in the current directory with the compilation graph description in Graphviz format (identical - to the file used by the ``--view-graph`` option). The ``-o`` option can be used - to set the output file name. Hidden option, useful for debugging LLVMC plugins. + to the file used by the ``--view-graph`` option). The ``-o`` option can be + used to set the output file name. Hidden option, useful for debugging LLVMC + plugins. * ``--save-temps`` - Write temporary files to the current directory and do not delete them on exit. Hidden option, useful for debugging. @@ -113,7 +114,6 @@ * ``--help``, ``--help-hidden``, ``--version`` - These options have their standard meaning. - Compiling LLVMC plugins ======================= @@ -146,14 +146,6 @@ $ mv Simple.td MyPlugin.td -Note that the plugin source directory must be placed under -``$LLVMC_DIR/plugins`` to make use of the existing build -infrastructure. To build a version of the LLVMC executable called -``mydriver`` with your plugin compiled in, use the following command:: - - $ cd $LLVMC_DIR - $ make BUILTIN_PLUGINS=MyPlugin DRIVER_NAME=mydriver - To build your plugin as a dynamic library, just ``cd`` to its source directory and run ``make``. The resulting file will be called ``LLVMC$(LLVMC_PLUGIN).$(DLL_EXTENSION)`` (in our case, @@ -164,11 +156,45 @@ $ make $ llvmc -load $LLVM_DIR/Release/lib/LLVMCSimple.so +Compiling standalone LLVMC-based drivers +======================================== + +By default, the ``llvmc`` executable consists of a driver core plus several +statically linked plugins (``Base`` and ``Clang`` at the moment). You can +produce a standalone LLVMC-based driver executable by linking the core with your +own plugins. The recommended way to do this is by starting with the provided +``Skeleton`` example (``$LLVMC_DIR/example/Skeleton``):: + + $ cd $LLVMC_DIR/example/ + $ cp -r Skeleton mydriver + $ cd mydriver + $ vim Makefile + [...] + $ make + +If you're compiling LLVM with different source and object directories, then you +must perform the following additional steps before running ``make``:: + + # LLVMC_SRC_DIR = $LLVM_SRC_DIR/tools/llvmc/ + # LLVMC_OBJ_DIR = $LLVM_OBJ_DIR/tools/llvmc/ + $ cp $LLVMC_SRC_DIR/example/mydriver/Makefile \ + $LLVMC_OBJ_DIR/example/mydriver/ + $ cd $LLVMC_OBJ_DIR/example/mydriver + $ make + +Another way to do the same thing is by using the following command:: + + $ cd $LLVMC_DIR + $ make LLVMC_BUILTIN_PLUGINS=MyPlugin LLVMC_BASED_DRIVER_NAME=mydriver + +This works with both srcdir==objdir and srcdir != objdir, but assumes that the +plugin source directory was placed under ``$LLVMC_DIR/plugins``. + Sometimes, you will want a 'bare-bones' version of LLVMC that has no built-in plugins. It can be compiled with the following command:: $ cd $LLVMC_DIR - $ make BUILTIN_PLUGINS="" + $ make LLVMC_BUILTIN_PLUGINS="" Customizing LLVMC: the compilation graph Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Tutorial.rst URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/doc/LLVMC-Tutorial.rst?rev=73448&r1=73447&r2=73448&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/doc/LLVMC-Tutorial.rst (original) +++ llvm/trunk/tools/llvmc/doc/LLVMC-Tutorial.rst Mon Jun 15 19:13:52 2009 @@ -48,21 +48,25 @@ .. _TableGen: http://llvm.cs.uiuc.edu/docs/TableGenFundamentals.html -Start by compiling ``plugins/Simple/Simple.td``, which is a primitive -wrapper for ``gcc``:: +Start by compiling ``example/Simple``, which is a primitive wrapper for +``gcc``:: $ cd $LLVM_DIR/tools/llvmc - $ make DRIVER_NAME=mygcc BUILTIN_PLUGINS=Simple + + # NB: A less verbose way to compile standalone LLVMC-based drivers is + # described in the reference manual. + + $ make LLVMC_BASED_DRIVER_NAME=mygcc LLVMC_BUILTIN_PLUGINS=Simple $ cat > hello.c [...] $ mygcc hello.c $ ./hello.out Hello -Here we link our plugin with the LLVMC core statically to form an -executable file called ``mygcc``. It is also possible to build our -plugin as a standalone dynamic library; this is described in the -reference manual. +Here we link our plugin with the LLVMC core statically to form an executable +file called ``mygcc``. It is also possible to build our plugin as a dynamic +library to be loaded by the ``llvmc`` executable (or any other LLVMC-based +standalone driver); this is described in the reference manual. Contents of the file ``Simple.td`` look like this:: From foldr at codedgers.com Mon Jun 15 19:14:20 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 16 Jun 2009 00:14:20 -0000 Subject: [llvm-commits] [llvm] r73449 - in /llvm/trunk/docs: CompilerDriver.html CompilerDriverTutorial.html Message-ID: <200906160014.n5G0ELuc014813@zion.cs.uiuc.edu> Author: foldr Date: Mon Jun 15 19:14:20 2009 New Revision: 73449 URL: http://llvm.org/viewvc/llvm-project?rev=73449&view=rev Log: Regenerate. Modified: llvm/trunk/docs/CompilerDriver.html llvm/trunk/docs/CompilerDriverTutorial.html Modified: llvm/trunk/docs/CompilerDriver.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CompilerDriver.html?rev=73449&r1=73448&r2=73449&view=diff ============================================================================== --- llvm/trunk/docs/CompilerDriver.html (original) +++ llvm/trunk/docs/CompilerDriver.html Mon Jun 15 19:14:20 2009 @@ -21,21 +21,22 @@
  • Compiling with LLVMC
  • Predefined options
  • Compiling LLVMC plugins
  • -
  • Customizing LLVMC: the compilation graph
  • -
  • Describing options
      -
    • External options
    • +
    • Compiling standalone LLVMC-based drivers
    • +
    • Customizing LLVMC: the compilation graph
    • +
    • Describing options
    • -
    • Conditional evaluation
    • -
    • Writing a tool description
        -
      • Actions
      • +
      • Conditional evaluation
      • +
      • Writing a tool description
      • -
      • Language map
      • -
      • More advanced topics @@ -110,16 +111,17 @@
      • -v - Enable verbose mode, i.e. print out all executed commands.
      • --check-graph - Check the compilation for common errors like mismatched output/input language names, multiple default edges and cycles. Because of -plugins, these checks can't be performed at compile-time. Exit with code zero if -no errors were found, and return the number of found errors otherwise. Hidden -option, useful for debugging LLVMC plugins.
      • +plugins, these checks can't be performed at compile-time. Exit with code zero +if no errors were found, and return the number of found errors +otherwise. Hidden option, useful for debugging LLVMC plugins.
      • --view-graph - Show a graphical representation of the compilation graph and exit. Requires that you have dot and gv programs installed. Hidden option, useful for debugging LLVMC plugins.
      • --write-graph - Write a compilation-graph.dot file in the current directory with the compilation graph description in Graphviz format (identical -to the file used by the --view-graph option). The -o option can be used -to set the output file name. Hidden option, useful for debugging LLVMC plugins.
      • +to the file used by the --view-graph option). The -o option can be +used to set the output file name. Hidden option, useful for debugging LLVMC +plugins.
      • --save-temps - Write temporary files to the current directory and do not delete them on exit. Hidden option, useful for debugging.
      • --help, --help-hidden, --version - These options have @@ -154,14 +156,6 @@
         $ mv Simple.td MyPlugin.td
         
        -

        Note that the plugin source directory must be placed under -$LLVMC_DIR/plugins to make use of the existing build -infrastructure. To build a version of the LLVMC executable called -mydriver with your plugin compiled in, use the following command:

        -
        -$ cd $LLVMC_DIR
        -$ make BUILTIN_PLUGINS=MyPlugin DRIVER_NAME=mydriver
        -

        To build your plugin as a dynamic library, just cd to its source directory and run make. The resulting file will be called LLVMC$(LLVMC_PLUGIN).$(DLL_EXTENSION) (in our case, @@ -172,15 +166,48 @@ $ make $ llvmc -load $LLVM_DIR/Release/lib/LLVMCSimple.so + +

        +

        Compiling standalone LLVMC-based drivers

        +

        By default, the llvmc executable consists of a driver core plus several +statically linked plugins (Base and Clang at the moment). You can +produce a standalone LLVMC-based driver executable by linking the core with your +own plugins. The recommended way to do this is by starting with the provided +Skeleton example ($LLVMC_DIR/example/Skeleton):

        +
        +$ cd $LLVMC_DIR/example/
        +$ cp -r Skeleton mydriver
        +$ cd mydriver
        +$ vim Makefile
        +[...]
        +$ make
        +
        +

        If you're compiling LLVM with different source and object directories, then you +must perform the following additional steps before running make:

        +
        +# LLVMC_SRC_DIR = $LLVM_SRC_DIR/tools/llvmc/
        +# LLVMC_OBJ_DIR = $LLVM_OBJ_DIR/tools/llvmc/
        +$ cp $LLVMC_SRC_DIR/example/mydriver/Makefile \
        +  $LLVMC_OBJ_DIR/example/mydriver/
        +$ cd $LLVMC_OBJ_DIR/example/mydriver
        +$ make
        +
        +

        Another way to do the same thing is by using the following command:

        +
        +$ cd $LLVMC_DIR
        +$ make LLVMC_BUILTIN_PLUGINS=MyPlugin LLVMC_BASED_DRIVER_NAME=mydriver
        +
        +

        This works with both srcdir==objdir and srcdir != objdir, but assumes that the +plugin source directory was placed under $LLVMC_DIR/plugins.

        Sometimes, you will want a 'bare-bones' version of LLVMC that has no built-in plugins. It can be compiled with the following command:

         $ cd $LLVMC_DIR
        -$ make BUILTIN_PLUGINS=""
        +$ make LLVMC_BUILTIN_PLUGINS=""
         
        -

        Customizing LLVMC: the compilation graph

        +

        Customizing LLVMC: the compilation graph

        Each TableGen configuration file should include the common definitions:

        @@ -248,7 +275,7 @@
         gsview installed for this to work properly.

        -

        Describing options

        +

        Describing options

        Command-line options that the plugin supports are defined by using an OptionList:

        @@ -317,7 +344,7 @@
         
      -

      External options

      +

      External options

      Sometimes, when linking several plugins together, one plugin needs to access options defined in some other plugin. Because of the way options are implemented, such options must be marked as @@ -332,7 +359,7 @@

      -

      Conditional evaluation

      +

      Conditional evaluation

      The 'case' construct is the main means by which programmability is achieved in LLVMC. It can be used to calculate edge weights, program actions and modify the shell commands to be executed. The 'case' @@ -412,7 +439,7 @@

    -

    Writing a tool description

    +

    Writing a tool description

    As was said earlier, nodes in the compilation graph represent tools, which are described separately. A tool definition looks like this (taken from the include/llvm/CompilerDriver/Tools.td file):

    @@ -454,7 +481,7 @@
  • -

    Actions

    +

    Actions

    A tool often needs to react to command-line options, and this is precisely what the actions property is for. The next example illustrates this feature:

    @@ -515,7 +542,7 @@
    -

    Language map

    +

    Language map

    If you are adding support for a new language to LLVMC, you'll need to modify the language map, which defines mappings from file extensions to language names. It is used to choose the proper toolchain(s) for a @@ -538,9 +565,9 @@ output languages should match. This is enforced at compile-time.

    -

    More advanced topics

    +

    More advanced topics

    -

    Hooks and environment variables

    +

    Hooks and environment variables

    Normally, LLVMC executes programs from the system PATH. Sometimes, this is not sufficient: for example, we may want to specify tool paths or names in the configuration file. This can be easily achieved via @@ -573,7 +600,7 @@

    -

    How plugins are loaded

    +

    How plugins are loaded

    It is possible for LLVMC plugins to depend on each other. For example, one can create edges between nodes defined in some other plugin. To make this work, however, that plugin should be loaded first. To @@ -589,7 +616,7 @@ loaded last.

    -

    Debugging

    +

    Debugging

    When writing LLVMC plugins, it can be useful to get a visual view of the resulting compilation graph. This can be achieved via the command line option --view-graph. This command assumes that Graphviz and Modified: llvm/trunk/docs/CompilerDriverTutorial.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CompilerDriverTutorial.html?rev=73449&r1=73448&r2=73449&view=diff ============================================================================== --- llvm/trunk/docs/CompilerDriverTutorial.html (original) +++ llvm/trunk/docs/CompilerDriverTutorial.html Mon Jun 15 19:14:20 2009 @@ -50,21 +50,25 @@

    Using LLVMC to generate toolchain drivers

    LLVMC plugins are written mostly using TableGen, so you need to be familiar with it to get anything done.

    -

    Start by compiling plugins/Simple/Simple.td, which is a primitive -wrapper for gcc:

    +

    Start by compiling example/Simple, which is a primitive wrapper for +gcc:

     $ cd $LLVM_DIR/tools/llvmc
    -$ make DRIVER_NAME=mygcc BUILTIN_PLUGINS=Simple
    +
    +  # NB: A less verbose way to compile standalone LLVMC-based drivers is
    +  # described in the reference manual.
    +
    +$ make LLVMC_BASED_DRIVER_NAME=mygcc LLVMC_BUILTIN_PLUGINS=Simple
     $ cat > hello.c
     [...]
     $ mygcc hello.c
     $ ./hello.out
     Hello
     
    -

    Here we link our plugin with the LLVMC core statically to form an -executable file called mygcc. It is also possible to build our -plugin as a standalone dynamic library; this is described in the -reference manual.

    +

    Here we link our plugin with the LLVMC core statically to form an executable +file called mygcc. It is also possible to build our plugin as a dynamic +library to be loaded by the llvmc executable (or any other LLVMC-based +standalone driver); this is described in the reference manual.

    Contents of the file Simple.td look like this:

     // Include common definitions
    
    
    
    
    From gohman at apple.com  Mon Jun 15 19:20:26 2009
    From: gohman at apple.com (Dan Gohman)
    Date: Tue, 16 Jun 2009 00:20:26 -0000
    Subject: [llvm-commits] [llvm] r73451 -
    	/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
    Message-ID: <200906160020.n5G0KQaq015052@zion.cs.uiuc.edu>
    
    Author: djg
    Date: Mon Jun 15 19:20:26 2009
    New Revision: 73451
    
    URL: http://llvm.org/viewvc/llvm-project?rev=73451&view=rev
    Log:
    Use Type::getScalarType.
    
    Modified:
        llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
    
    Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=73451&r1=73450&r2=73451&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
    +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Mon Jun 15 19:20:26 2009
    @@ -820,10 +820,8 @@
               StoreVal = Constant::getNullValue(EltTy);  // 0.0, null, 0, <0,0>
             } else {
               // If EltTy is a vector type, get the element type.
    -          const Type *ValTy = EltTy;
    -          if (const VectorType *VTy = dyn_cast(ValTy))
    -            ValTy = VTy->getElementType();
    -          
    +          const Type *ValTy = EltTy->getScalarType();
    +
               // Construct an integer with the right value.
               unsigned EltSize = TD->getTypeSizeInBits(ValTy);
               APInt OneVal(EltSize, CI->getZExtValue());
    
    
    
    
    From gohman at apple.com  Mon Jun 15 19:22:12 2009
    From: gohman at apple.com (Dan Gohman)
    Date: Mon, 15 Jun 2009 17:22:12 -0700
    Subject: [llvm-commits] [llvm] r73431 - in /llvm/trunk: include/llvm/
    	include/llvm/Analysis/ lib/Analysis/	lib/Transforms/Instrumentation/
    	lib/Transforms/Scalar/	lib/VMCore/	test/Feature/	test/Transforms/InstCombine/
    In-Reply-To: <46812640-6BBE-441A-A4A8-9891E8CBAB16@apple.com>
    References: <200906152212.n5FMCuvr010609@zion.cs.uiuc.edu>
    	<614E1E90-F8B1-40AA-86A2-101434BE1E77@apple.com>
    	<9ED72EF9-444F-4AEF-A7C6-8DC507F4CAD2@apple.com>
    	<46812640-6BBE-441A-A4A8-9891E8CBAB16@apple.com>
    Message-ID: <68B5AFE6-53E2-46FA-8318-1C9A77052459@apple.com>
    
    
    On Jun 15, 2009, at 4:57 PM, Chris Lattner wrote:
    
    
    >
    > On Jun 15, 2009, at 4:33 PM, Dan Gohman wrote:
    >
    >
    >>> Hi Dan,
    >>>
    >>>
    >>>
    >>> Why should ConstantInt/FP::get allow a vector operand?  It seems  
    >>> very
    >>>
    >>> strange to me to allow this.
    >>>
    >>
    >>
    >> It's a convenience for code that handles both vector and scalar
    >>
    >> values. In the same sense that the vector form of an add is an
    >>
    >> add that applies to each element of a vector, the vector form
    >>
    >> of a constant is a constant vector with each element equal to
    >>
    >> the constant.
    >>
    >
    > The part that confuses me is that code should generally know when it
    > is working on a vector or not.  Is ConstantInt::get(4, )
    > better than ConstantVector::get(4, ) ?
    
    There are lots of places where vector/scalar-independent code
    is useful. As one example, the instcombine code that converts
    
       %b = trunc i64 %a to i32
       %c = zext i32 %b to i64
    to
       %c = and i64, 4294967295
    
    now performs the same optimization for vectors, as a result
    of this commit.
    
    >
    >
    >
    >>> In general, please split up logically distinct changes into  
    >>> different
    >>>
    >>> pieces, it would be nice to have the core IR changes separately from
    >>>
    >>> the SCEV changes,
    >>>
    >>
    >>
    >> The SCEV changes here were needed in order to conform to
    >>
    >> the core IR API changes.
    >>
    >
    > Ok, but couldn't the API changes go in first?
    
    Not without breaking the build. I probably could have
    split the new convenience function out into a separate
    patch, but that would have made the SCEV changes in the
    original patch more verbose.
    
    Dan
    
    
    
    From resistor at mac.com  Mon Jun 15 19:29:41 2009
    From: resistor at mac.com (Owen Anderson)
    Date: Mon, 15 Jun 2009 17:29:41 -0700
    Subject: [llvm-commits] [PATCH] LockedManagedStatic
    In-Reply-To: <0DBD89AB-971A-4367-BE69-8DE2533752CA@mac.com>
    References: <0DBD89AB-971A-4367-BE69-8DE2533752CA@mac.com>
    Message-ID: <6EFD908D-2870-4ED4-8624-7E3FF7E69F3E@mac.com>
    
    Just for everyone's information, Chris and I discussed this patch  
    offline, and we think we have a much better version planned.
    
    --Owen
    
    On Jun 15, 2009, at 10:16 AM, Owen Anderson wrote:
    
    > Here's my next proposal for the long-term goal of making LLVM thread- 
    > safe.  The concept here is to create a new subclass of  
    > ManagedStaticBase, LockedManagedStatic.  These objects pair a mutex  
    > with the object that they're guarding, and hook the mutex up to be  
    > initialized automatically when llvm_start_multithreaded() is called.
    >
    > This does have slight overhead in that it adds a pointer to  
    > ManagedStaticBase.  This could probably be avoided by adding another  
    > class to the hierarch (LockedManagedStaticBase?), but that seemed  
    > overly complex for fairly small benefit.
    >
    > Comments welcome!
    >
    > --Owen
    >
    > _______________________________________________
    > llvm-commits mailing list
    > llvm-commits at cs.uiuc.edu
    > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
    
    
    
    From clattner at apple.com  Mon Jun 15 19:35:53 2009
    From: clattner at apple.com (Chris Lattner)
    Date: Mon, 15 Jun 2009 17:35:53 -0700
    Subject: [llvm-commits] [llvm] r73431 - in /llvm/trunk: include/llvm/
    	include/llvm/Analysis/ lib/Analysis/	lib/Transforms/Instrumentation/
    	lib/Transforms/Scalar/	lib/VMCore/	test/Feature/	test/Transforms/InstCombine/
    In-Reply-To: <68B5AFE6-53E2-46FA-8318-1C9A77052459@apple.com>
    References: <200906152212.n5FMCuvr010609@zion.cs.uiuc.edu>
    	<614E1E90-F8B1-40AA-86A2-101434BE1E77@apple.com>
    	<9ED72EF9-444F-4AEF-A7C6-8DC507F4CAD2@apple.com>
    	<46812640-6BBE-441A-A4A8-9891E8CBAB16@apple.com>
    	<68B5AFE6-53E2-46FA-8318-1C9A77052459@apple.com>
    Message-ID: 
    
    
    On Jun 15, 2009, at 5:22 PM, Dan Gohman wrote:
    
    >>
    >> The part that confuses me is that code should generally know when it
    >> is working on a vector or not.  Is ConstantInt::get(4, )
    >> better than ConstantVector::get(4, ) ?
    >
    > There are lots of places where vector/scalar-independent code
    > is useful. As one example, the instcombine code that converts
    >
    >   %b = trunc i64 %a to i32
    >   %c = zext i32 %b to i64
    > to
    >   %c = and i64, 4294967295
    >
    > now performs the same optimization for vectors, as a result
    > of this commit.
    
    Ok then.  Please make it really clear in the doxygen documentation for  
    these methods that this is allowed, thanks Dan!
    
    -Chris
    
    
    From gohman at apple.com  Mon Jun 15 20:02:33 2009
    From: gohman at apple.com (Dan Gohman)
    Date: Tue, 16 Jun 2009 01:02:33 -0000
    Subject: [llvm-commits] [llvm] r73454 - /llvm/trunk/include/llvm/Constants.h
    Message-ID: <200906160102.n5G12XP5016509@zion.cs.uiuc.edu>
    
    Author: djg
    Date: Mon Jun 15 20:02:32 2009
    New Revision: 73454
    
    URL: http://llvm.org/viewvc/llvm-project?rev=73454&view=rev
    Log:
    Add comments to ConstantInt::get and ConstantFP::get to more fully
    describe their behavior.
    
    Modified:
        llvm/trunk/include/llvm/Constants.h
    
    Modified: llvm/trunk/include/llvm/Constants.h
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=73454&r1=73453&r2=73454&view=diff
    
    ==============================================================================
    --- llvm/trunk/include/llvm/Constants.h (original)
    +++ llvm/trunk/include/llvm/Constants.h Mon Jun 15 20:02:32 2009
    @@ -102,13 +102,17 @@
         return CreateTrueFalseVals(false);
       }
     
    -  /// Return a ConstantInt with the specified value for the specified type. The
    -  /// value V will be canonicalized to an unsigned APInt. Accessing it with
    -  /// either getSExtValue() or getZExtValue() will yield a correctly sized and
    -  /// signed value for the type Ty.
    +  /// Return a ConstantInt with the specified integer value for the specified
    +  /// type. If the type is wider than 64 bits, the value will be zero-extended
    +  /// to fit the type, unless isSigned is true, in which case the value will
    +  /// be interpreted as a 64-bit signed integer and sign-extended to fit
    +  /// the type.
       /// @brief Get a ConstantInt for a specific value.
       static ConstantInt *get(const IntegerType *Ty,
                               uint64_t V, bool isSigned = false);
    +
    +  /// If Ty is a vector type, return a Constant with a splat of the given
    +  /// value. Otherwise return a ConstantInt for the given value.
       static Constant *get(const Type *Ty, uint64_t V, bool isSigned = false);
     
       /// Return a ConstantInt with the specified value for the specified type. The
    @@ -257,9 +261,10 @@
       /// get() - Static factory methods - Return objects of the specified value
       static ConstantFP *get(const APFloat &V);
     
    -  /// get() - This returns a constant fp for the specified value in the
    -  /// specified type.  This should only be used for simple constant values like
    -  /// 2.0/1.0 etc, that are known-valid both as double and as the target format.
    +  /// get() - This returns a ConstantFP, or a vector containing a splat of a
    +  /// ConstantFP, for the specified value in the specified type.  This should
    +  /// only be used for simple constant values like 2.0/1.0 etc, that are
    +  /// known-valid both as host double and as the target format.
       static Constant *get(const Type *Ty, double V);
     
       /// isValueValidForType - return true if Ty is big enough to represent V.
    
    
    
    
    From resistor at mac.com  Mon Jun 15 20:17:16 2009
    From: resistor at mac.com (Owen Anderson)
    Date: Tue, 16 Jun 2009 01:17:16 -0000
    Subject: [llvm-commits] [llvm] r73456 -
    	/llvm/trunk/docs/ProgrammersManual.html
    Message-ID: <200906160117.n5G1HGhe016958@zion.cs.uiuc.edu>
    
    Author: resistor
    Date: Mon Jun 15 20:17:16 2009
    New Revision: 73456
    
    URL: http://llvm.org/viewvc/llvm-project?rev=73456&view=rev
    Log:
    Add initial stab at documenting the use of LLVM with threaded clients.
    
    Comments welcome!
    
    Modified:
        llvm/trunk/docs/ProgrammersManual.html
    
    Modified: llvm/trunk/docs/ProgrammersManual.html
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=73456&r1=73455&r2=73456&view=diff
    
    ==============================================================================
    --- llvm/trunk/docs/ProgrammersManual.html (original)
    +++ llvm/trunk/docs/ProgrammersManual.html Mon Jun 15 20:17:16 2009
    @@ -129,6 +129,14 @@
         
       
     
    +  
  • Threads and LLVM + +
  • +
  • Advanced Topics
  • @@ -2131,6 +2140,104 @@ + + +
    +

    +This section describes the interaction of the LLVM APIs with multithreading, +both on the part of client applications, and in the JIT, in the hosted +application. +

    + +

    +Note that LLVM's support for multithreading is still relatively young. Up +through version 2.5, the execution of threaded hosted applications was +supported, but not threaded client access to the APIs. While this use case is +now supported, clients must adhere to the guidelines specified below to +ensure proper operation in multithreaded mode. +

    + +

    +Note that, on Unix-like platforms, LLVM requires the presence of GCC's atomic +intrinsics in order to support threaded operation. If you need a +multhreading-capable LLVM on a platform without a suitably modern system +compiler, consider compiling LLVM and LLVM-GCC in single-threaded mode, and +using the resultant compiler to build a copy of LLVM with multithreading +support. +

    +
    + + + + +
    + +

    +In order to properly protect its internal data structures while avoiding +excessive locking overhead in the single-threaded case, the LLVM APIs require +that the client invoke llvm_start_multithreaded(). This call must +complete before any other threads attempt to invoke LLVM APIs. Any +attempts to call LLVM APIs from multiple threads before +llvm_start_multithreaded returns can and will cause corruption of +LLVM's internal data. +

    + +

    +A caveat: before llvm_start_multithreaded() has been invoked, all +llvm::sys::Mutex acquisitions and releases will become no-ops. This +means that llvm_start_multithreaded() must be invoked before a threaded +application can be executed in the JIT. +

    +
    + + + + +
    +

    +When you are done using the LLVM APIs, you should call llvm_shutdown() +to deallocate memory used for internal structures. This call must not begin +while any other threads are still issuing LLVM API calls. Doing so is likely +to result in garbage data or crashes. +

    + +

    +Note that, if you use scope-based shutdown, you can use the +llvm_shutdown_obj class, which calls llvm_shutdown() in its +destructor. +

    + + + + +
    +

    +ManagedStatic is a utility class in LLVM used to implement static +initialization of static resources, such as the global type tables. Before the +invocation of llvm_shutdown(), it implements a simple lazy +initialization scheme. Once llvm_start_multithreaded() returns, +however, it uses double-checked locking to implement thread-safe lazy +initialization. +

    + +

    +Note that, because no other threads are allowed to issue LLVM API calls before +llvm_start_multithreaded() returns, it is possible to have +ManagedStatics of llvm::sys::Mutexs. +

    +
    + + + From dpatel at apple.com Mon Jun 15 21:09:30 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 16 Jun 2009 02:09:30 -0000 Subject: [llvm-commits] [llvm] r73457 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/DebugInfo/2009-06-15-abstract_origin.ll Message-ID: <200906160209.n5G29U09018790@zion.cs.uiuc.edu> Author: dpatel Date: Mon Jun 15 21:09:30 2009 New Revision: 73457 URL: http://llvm.org/viewvc/llvm-project?rev=73457&view=rev Log: Use MainCU if it is available. Added: llvm/trunk/test/DebugInfo/2009-06-15-abstract_origin.ll 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=73457&r1=73456&r2=73457&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Jun 15 21:09:30 2009 @@ -1757,6 +1757,9 @@ if (TimePassesIsEnabled) DebugTimer->startTimer(); + CompileUnit *Unit = MainCU; + if (!Unit) + Unit = &FindCompileUnit(SP.getCompileUnit()); GlobalVariable *GV = SP.getGV(); DenseMap::iterator II = AbstractInstanceRootMap.find(GV); @@ -1767,7 +1770,6 @@ DbgScope *Scope = new DbgScope(NULL, DIDescriptor(GV)); // Get the compile unit context. - CompileUnit *Unit = &FindCompileUnit(SP.getCompileUnit()); DIE *SPDie = Unit->getDieMapSlotFor(GV); if (!SPDie) SPDie = CreateSubprogramDIE(Unit, SP, false, true); @@ -1789,7 +1791,6 @@ // Create a concrete inlined instance for this inlined function. DbgConcreteScope *ConcreteScope = new DbgConcreteScope(DIDescriptor(GV)); DIE *ScopeDie = new DIE(dwarf::DW_TAG_inlined_subroutine); - CompileUnit *Unit = &FindCompileUnit(SP.getCompileUnit()); ScopeDie->setAbstractCompileUnit(Unit); DIE *Origin = Unit->getDieMapSlotFor(GV); Added: llvm/trunk/test/DebugInfo/2009-06-15-abstract_origin.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-06-15-abstract_origin.ll?rev=73457&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-06-15-abstract_origin.ll (added) +++ llvm/trunk/test/DebugInfo/2009-06-15-abstract_origin.ll Mon Jun 15 21:09:30 2009 @@ -0,0 +1,275 @@ +; RUN: llvm-as < %s | llc -asm-verbose -O0 | not grep ".long 0x0 ## DW_AT_abstract_origin" + + %llvm.dbg.anchor.type = type { i32, i32 } + %llvm.dbg.basictype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, i32 } + %llvm.dbg.compile_unit.type = type { i32, { }*, i32, i8*, i8*, i8*, i1, i1, i8*, i32 } + %llvm.dbg.composite.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, { }*, { }*, i32 } + %llvm.dbg.derivedtype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, { }* } + %llvm.dbg.global_variable.type = type { i32, { }*, { }*, i8*, i8*, i8*, { }*, i32, { }*, i1, i1, { }* } + %llvm.dbg.subprogram.type = type { i32, { }*, { }*, i8*, i8*, i8*, { }*, i32, { }*, i1, i1 } + %llvm.dbg.variable.type = type { i32, { }*, i8*, { }*, i32, { }* } + %struct.AAAAAImageParser = type { %struct.CObject* } + %struct.CObject = type { i32 } + at llvm.dbg.compile_units = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 17 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] + at .str = internal constant [9 x i8] c"tcase.cc\00", section "llvm.metadata" ; <[9 x i8]*> [#uses=1] + at .str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata" ; <[6 x i8]*> [#uses=1] + at .str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5646) (LLVM build 00)\00", section "llvm.metadata" ; <[55 x i8]*> [#uses=1] + at llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 4, i8* getelementptr ([9 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null, i32 0 }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] + at .str3 = internal constant [8 x i8] c"tcase.h\00", section "llvm.metadata" ; <[8 x i8]*> [#uses=1] + at llvm.dbg.compile_unit4 = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 4, i8* getelementptr ([8 x i8]* @.str3, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 false, i1 false, i8* null, i32 0 }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] + at .str5 = internal constant [8 x i8] c"CObject\00", section "llvm.metadata" ; <[8 x i8]*> [#uses=1] + at .str6 = internal constant [4 x i8] c"int\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] + at llvm.dbg.basictype = internal constant %llvm.dbg.basictype.type { i32 458788, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str6, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 32, i64 32, i64 0, i32 0, i32 5 }, section "llvm.metadata" ; <%llvm.dbg.basictype.type*> [#uses=1] + at .str7 = internal constant [2 x i8] c"d\00", section "llvm.metadata" ; <[2 x i8]*> [#uses=1] + at llvm.dbg.derivedtype = internal constant %llvm.dbg.derivedtype.type { i32 458765, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([2 x i8]* @.str7, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 6, i64 32, i64 32, i64 0, i32 1, { }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] + at llvm.dbg.derivedtype8 = internal constant %llvm.dbg.derivedtype.type { i32 458767, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 32, i64 32, i64 0, i32 0, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite18 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] + at llvm.dbg.array = internal constant [3 x { }*] [{ }* null, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype8 to { }*), { }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*)], section "llvm.metadata" ; <[3 x { }*]*> [#uses=1] + at llvm.dbg.composite9 = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([3 x { }*]* @llvm.dbg.array to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at llvm.dbg.subprograms = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 46 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] + at .str10 = internal constant [4 x i8] c"set\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] + at .str11 = internal constant [18 x i8] c"_ZN7CObject3setEi\00", section "llvm.metadata" ; <[18 x i8]*> [#uses=1] + at llvm.dbg.subprogram = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str10, i32 0, i32 0), i8* getelementptr ([4 x i8]* @.str10, i32 0, i32 0), i8* getelementptr ([18 x i8]* @.str11, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 3, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite9 to { }*), i1 false, i1 false }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at llvm.dbg.array12 = internal constant [2 x { }*] [{ }* null, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype8 to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] + at llvm.dbg.composite13 = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array12 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at .str14 = internal constant [8 x i8] c"release\00", section "llvm.metadata" ; <[8 x i8]*> [#uses=1] + at .str15 = internal constant [22 x i8] c"_ZN7CObject7releaseEv\00", section "llvm.metadata" ; <[22 x i8]*> [#uses=1] + at llvm.dbg.subprogram16 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([8 x i8]* @.str14, i32 0, i32 0), i8* getelementptr ([8 x i8]* @.str14, i32 0, i32 0), i8* getelementptr ([22 x i8]* @.str15, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 4, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite13 to { }*), i1 false, i1 false }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at llvm.dbg.array17 = internal constant [3 x { }*] [{ }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype to { }*), { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram to { }*), { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram16 to { }*)], section "llvm.metadata" ; <[3 x { }*]*> [#uses=1] + at llvm.dbg.composite18 = internal constant %llvm.dbg.composite.type { i32 458771, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([8 x i8]* @.str5, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 1, i64 32, i64 32, i64 0, i32 0, { }* null, { }* bitcast ([3 x { }*]* @llvm.dbg.array17 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at llvm.dbg.derivedtype19 = internal constant %llvm.dbg.derivedtype.type { i32 458767, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 32, i64 32, i64 0, i32 0, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite18 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] + at llvm.dbg.array20 = internal constant [2 x { }*] [{ }* null, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype19 to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] + at llvm.dbg.composite = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array20 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at llvm.dbg.subprogram21 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([8 x i8]* @.str14, i32 0, i32 0), i8* getelementptr ([8 x i8]* @.str14, i32 0, i32 0), i8* getelementptr ([22 x i8]* @.str15, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 4, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at llvm.dbg.derivedtype22 = internal constant %llvm.dbg.derivedtype.type { i32 458790, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 32, i64 32, i64 0, i32 0, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype19 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] + at .str23 = internal constant [5 x i8] c"this\00", section "llvm.metadata" ; <[5 x i8]*> [#uses=1] + at llvm.dbg.variable = internal constant %llvm.dbg.variable.type { i32 459009, { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram21 to { }*), i8* getelementptr ([5 x i8]* @.str23, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 4, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype22 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.variable.type*> [#uses=1] + at llvm.dbg.array24 = internal constant [2 x { }*] [{ }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype19 to { }*), { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype19 to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] + at llvm.dbg.composite25 = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array24 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at .str26 = internal constant [14 x i8] c"ReleaseObject\00", section "llvm.metadata" ; <[14 x i8]*> [#uses=1] + at .str27 = internal constant [27 x i8] c"_Z13ReleaseObjectP7CObject\00", section "llvm.metadata" ; <[27 x i8]*> [#uses=1] + at llvm.dbg.subprogram28 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([14 x i8]* @.str26, i32 0, i32 0), i8* getelementptr ([14 x i8]* @.str26, i32 0, i32 0), i8* getelementptr ([27 x i8]* @.str27, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 10, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite25 to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at .str29 = internal constant [7 x i8] c"object\00", section "llvm.metadata" ; <[7 x i8]*> [#uses=1] + at llvm.dbg.variable30 = internal constant %llvm.dbg.variable.type { i32 459009, { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram28 to { }*), i8* getelementptr ([7 x i8]* @.str29, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 10, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype22 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.variable.type*> [#uses=1] + at .str31 = internal constant [17 x i8] c"AAAAAImageParser\00", section "llvm.metadata" ; <[17 x i8]*> [#uses=1] + at .str33 = internal constant [13 x i8] c"mCustomWhite\00", section "llvm.metadata" ; <[13 x i8]*> [#uses=1] + at llvm.dbg.derivedtype34 = internal constant %llvm.dbg.derivedtype.type { i32 458765, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([13 x i8]* @.str33, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 21, i64 32, i64 32, i64 0, i32 1, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype19 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] + at llvm.dbg.derivedtype35 = internal constant %llvm.dbg.derivedtype.type { i32 458767, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 32, i64 32, i64 0, i32 0, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite45 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] + at llvm.dbg.array36 = internal constant [3 x { }*] [{ }* null, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype35 to { }*), { }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*)], section "llvm.metadata" ; <[3 x { }*]*> [#uses=1] + at llvm.dbg.composite37 = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([3 x { }*]* @llvm.dbg.array36 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at .str38 = internal constant [18 x i8] c"~AAAAAImageParser\00", section "llvm.metadata" ; <[18 x i8]*> [#uses=1] + at llvm.dbg.subprogram39 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([18 x i8]* @.str38, i32 0, i32 0), i8* getelementptr ([18 x i8]* @.str38, i32 0, i32 0), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 24, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite37 to { }*), i1 false, i1 false }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at llvm.dbg.array40 = internal constant [3 x { }*] [{ }* null, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype35 to { }*), { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype19 to { }*)], section "llvm.metadata" ; <[3 x { }*]*> [#uses=1] + at llvm.dbg.composite41 = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([3 x { }*]* @llvm.dbg.array40 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at .str42 = internal constant [36 x i8] c"_ZN16AAAAAImageParser3setEP7CObject\00", section "llvm.metadata" ; <[36 x i8]*> [#uses=1] + at llvm.dbg.subprogram43 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([4 x i8]* @.str10, i32 0, i32 0), i8* getelementptr ([4 x i8]* @.str10, i32 0, i32 0), i8* getelementptr ([36 x i8]* @.str42, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 19, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite41 to { }*), i1 false, i1 false }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at llvm.dbg.array44 = internal constant [3 x { }*] [{ }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype34 to { }*), { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram39 to { }*), { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram43 to { }*)], section "llvm.metadata" ; <[3 x { }*]*> [#uses=1] + at llvm.dbg.composite45 = internal constant %llvm.dbg.composite.type { i32 458771, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([17 x i8]* @.str31, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 16, i64 32, i64 32, i64 0, i32 0, { }* null, { }* bitcast ([3 x { }*]* @llvm.dbg.array44 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at llvm.dbg.derivedtype46 = internal constant %llvm.dbg.derivedtype.type { i32 458767, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 32, i64 32, i64 0, i32 0, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite45 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] + at llvm.dbg.array47 = internal constant [2 x { }*] [{ }* null, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype46 to { }*)], section "llvm.metadata" ; <[2 x { }*]*> [#uses=1] + at llvm.dbg.composite48 = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([2 x { }*]* @llvm.dbg.array47 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at .str49 = internal constant [26 x i8] c"_ZN16AAAAAImageParserD2Ev\00", section "llvm.metadata" ; <[26 x i8]*> [#uses=1] + at llvm.dbg.subprogram50 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([18 x i8]* @.str38, i32 0, i32 0), i8* getelementptr ([18 x i8]* @.str38, i32 0, i32 0), i8* getelementptr ([26 x i8]* @.str49, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 24, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite48 to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at llvm.dbg.derivedtype51 = internal constant %llvm.dbg.derivedtype.type { i32 458790, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 32, i64 32, i64 0, i32 0, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype46 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.derivedtype.type*> [#uses=1] + at llvm.dbg.variable52 = internal constant %llvm.dbg.variable.type { i32 459009, { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram50 to { }*), i8* getelementptr ([5 x i8]* @.str23, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 24, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype51 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.variable.type*> [#uses=1] + at .str53 = internal constant [26 x i8] c"_ZN16AAAAAImageParserD1Ev\00", section "llvm.metadata" ; <[26 x i8]*> [#uses=1] + at llvm.dbg.subprogram54 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([18 x i8]* @.str38, i32 0, i32 0), i8* getelementptr ([18 x i8]* @.str38, i32 0, i32 0), i8* getelementptr ([26 x i8]* @.str53, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 24, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite48 to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at llvm.dbg.variable55 = internal constant %llvm.dbg.variable.type { i32 459009, { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram54 to { }*), i8* getelementptr ([5 x i8]* @.str23, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*), i32 24, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype51 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.variable.type*> [#uses=1] + at llvm.dbg.array56 = internal constant [1 x { }*] [{ }* bitcast (%llvm.dbg.basictype.type* @llvm.dbg.basictype to { }*)], section "llvm.metadata" ; <[1 x { }*]*> [#uses=1] + at llvm.dbg.composite57 = internal constant %llvm.dbg.composite.type { i32 458773, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* null, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 0, i64 0, i64 0, i64 0, i32 0, { }* null, { }* bitcast ([1 x { }*]* @llvm.dbg.array56 to { }*), i32 0 }, section "llvm.metadata" ; <%llvm.dbg.composite.type*> [#uses=1] + at .str58 = internal constant [5 x i8] c"main\00", section "llvm.metadata" ; <[5 x i8]*> [#uses=1] + at llvm.dbg.subprogram59 = internal constant %llvm.dbg.subprogram.type { i32 458798, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.subprograms to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([5 x i8]* @.str58, i32 0, i32 0), i8* getelementptr ([5 x i8]* @.str58, i32 0, i32 0), i8* getelementptr ([5 x i8]* @.str58, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 3, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite57 to { }*), i1 false, i1 true }, section "llvm.metadata" ; <%llvm.dbg.subprogram.type*> [#uses=1] + at .str60 = internal constant [2 x i8] c"C\00", section "llvm.metadata" ; <[2 x i8]*> [#uses=1] + at llvm.dbg.variable61 = internal constant %llvm.dbg.variable.type { i32 459008, { }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram59 to { }*), i8* getelementptr ([2 x i8]* @.str60, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 4, { }* bitcast (%llvm.dbg.derivedtype.type* @llvm.dbg.derivedtype46 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.variable.type*> [#uses=1] + at _ZZ4mainE3C.0 = private constant %struct.AAAAAImageParser zeroinitializer ; <%struct.AAAAAImageParser*> [#uses=2] + at llvm.dbg.global_variables = linkonce constant %llvm.dbg.anchor.type { i32 458752, i32 52 }, section "llvm.metadata" ; <%llvm.dbg.anchor.type*> [#uses=1] + at .str62 = internal constant [14 x i8] c"_ZZ4mainE3C.0\00", section "llvm.metadata" ; <[14 x i8]*> [#uses=1] + at .str63 = internal constant [4 x i8] c"C.0\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] + at llvm.dbg.global_variable = internal constant %llvm.dbg.global_variable.type { i32 458804, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.global_variables to { }*), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i8* getelementptr ([14 x i8]* @.str62, i32 0, i32 0), i8* getelementptr ([4 x i8]* @.str63, i32 0, i32 0), i8* getelementptr ([14 x i8]* @.str62, i32 0, i32 0), { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*), i32 4, { }* bitcast (%llvm.dbg.composite.type* @llvm.dbg.composite45 to { }*), i1 false, i1 true, { }* bitcast (%struct.AAAAAImageParser* @_ZZ4mainE3C.0 to { }*) }, section "llvm.metadata" ; <%llvm.dbg.global_variable.type*> [#uses=0] + +define void @_ZN16AAAAAImageParserD2Ev(%struct.AAAAAImageParser* %this) nounwind ssp { +entry: + %object_addr.i = alloca %struct.CObject* ; <%struct.CObject**> [#uses=4] + %retval.i = alloca %struct.CObject* ; <%struct.CObject**> [#uses=2] + %0 = alloca %struct.CObject* ; <%struct.CObject**> [#uses=2] + %this_addr = alloca %struct.AAAAAImageParser* ; <%struct.AAAAAImageParser**> [#uses=3] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram50 to { }*)) + %1 = bitcast %struct.AAAAAImageParser** %this_addr to { }* ; <{ }*> [#uses=1] + call void @llvm.dbg.declare({ }* %1, { }* bitcast (%llvm.dbg.variable.type* @llvm.dbg.variable52 to { }*)) + store %struct.AAAAAImageParser* %this, %struct.AAAAAImageParser** %this_addr + call void @llvm.dbg.stoppoint(i32 26, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) + %2 = load %struct.AAAAAImageParser** %this_addr, align 4 ; <%struct.AAAAAImageParser*> [#uses=1] + %3 = getelementptr %struct.AAAAAImageParser* %2, i32 0, i32 0 ; <%struct.CObject**> [#uses=1] + %4 = load %struct.CObject** %3, align 4 ; <%struct.CObject*> [#uses=1] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram28 to { }*)) nounwind + %5 = bitcast %struct.CObject** %object_addr.i to { }* ; <{ }*> [#uses=1] + call void @llvm.dbg.declare({ }* %5, { }* bitcast (%llvm.dbg.variable.type* @llvm.dbg.variable30 to { }*)) nounwind + store %struct.CObject* %4, %struct.CObject** %object_addr.i + call void @llvm.dbg.stoppoint(i32 11, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) nounwind + %6 = load %struct.CObject** %object_addr.i, align 4 ; <%struct.CObject*> [#uses=1] + %7 = icmp ne %struct.CObject* %6, null ; [#uses=1] + br i1 %7, label %bb.i, label %_Z13ReleaseObjectP7CObject.exit + +bb.i: ; preds = %entry + call void @llvm.dbg.stoppoint(i32 12, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) nounwind + %8 = load %struct.CObject** %object_addr.i, align 4 ; <%struct.CObject*> [#uses=1] + call void @_ZN7CObject7releaseEv(%struct.CObject* %8) nounwind + br label %_Z13ReleaseObjectP7CObject.exit + +_Z13ReleaseObjectP7CObject.exit: ; preds = %bb.i, %entry + call void @llvm.dbg.stoppoint(i32 13, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) nounwind + store %struct.CObject* null, %struct.CObject** %0, align 4 + %9 = load %struct.CObject** %0, align 4 ; <%struct.CObject*> [#uses=1] + store %struct.CObject* %9, %struct.CObject** %retval.i, align 4 + %retval2.i = load %struct.CObject** %retval.i ; <%struct.CObject*> [#uses=0] + call void @llvm.dbg.stoppoint(i32 13, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) nounwind + call void @llvm.dbg.stoppoint(i32 27, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram28 to { }*)) + br label %bb + +bb: ; preds = %_Z13ReleaseObjectP7CObject.exit + call void @llvm.dbg.stoppoint(i32 27, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) + br label %return + +return: ; preds = %bb + call void @llvm.dbg.stoppoint(i32 27, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram50 to { }*)) + ret void +} + +define linkonce_odr void @_ZN7CObject7releaseEv(%struct.CObject* %this) nounwind ssp { +entry: + %this_addr = alloca %struct.CObject* ; <%struct.CObject**> [#uses=3] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram21 to { }*)) + %0 = bitcast %struct.CObject** %this_addr to { }* ; <{ }*> [#uses=1] + call void @llvm.dbg.declare({ }* %0, { }* bitcast (%llvm.dbg.variable.type* @llvm.dbg.variable to { }*)) + store %struct.CObject* %this, %struct.CObject** %this_addr + call void @llvm.dbg.stoppoint(i32 4, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) + %1 = load %struct.CObject** %this_addr, align 4 ; <%struct.CObject*> [#uses=1] + %2 = getelementptr %struct.CObject* %1, i32 0, i32 0 ; [#uses=1] + store i32 0, i32* %2, align 4 + br label %return + +return: ; preds = %entry + call void @llvm.dbg.stoppoint(i32 4, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram21 to { }*)) + ret void +} + +declare void @llvm.dbg.func.start({ }*) nounwind readnone + +declare void @llvm.dbg.declare({ }*, { }*) nounwind readnone + +declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind readnone + +declare void @llvm.dbg.region.end({ }*) nounwind readnone + +define void @_ZN16AAAAAImageParserD1Ev(%struct.AAAAAImageParser* %this) nounwind ssp { +entry: + %object_addr.i = alloca %struct.CObject* ; <%struct.CObject**> [#uses=4] + %retval.i = alloca %struct.CObject* ; <%struct.CObject**> [#uses=2] + %0 = alloca %struct.CObject* ; <%struct.CObject**> [#uses=2] + %this_addr = alloca %struct.AAAAAImageParser* ; <%struct.AAAAAImageParser**> [#uses=3] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram54 to { }*)) + %1 = bitcast %struct.AAAAAImageParser** %this_addr to { }* ; <{ }*> [#uses=1] + call void @llvm.dbg.declare({ }* %1, { }* bitcast (%llvm.dbg.variable.type* @llvm.dbg.variable55 to { }*)) + store %struct.AAAAAImageParser* %this, %struct.AAAAAImageParser** %this_addr + call void @llvm.dbg.stoppoint(i32 26, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) + %2 = load %struct.AAAAAImageParser** %this_addr, align 4 ; <%struct.AAAAAImageParser*> [#uses=1] + %3 = getelementptr %struct.AAAAAImageParser* %2, i32 0, i32 0 ; <%struct.CObject**> [#uses=1] + %4 = load %struct.CObject** %3, align 4 ; <%struct.CObject*> [#uses=1] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram28 to { }*)) nounwind + %5 = bitcast %struct.CObject** %object_addr.i to { }* ; <{ }*> [#uses=1] + call void @llvm.dbg.declare({ }* %5, { }* bitcast (%llvm.dbg.variable.type* @llvm.dbg.variable30 to { }*)) nounwind + store %struct.CObject* %4, %struct.CObject** %object_addr.i + call void @llvm.dbg.stoppoint(i32 11, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) nounwind + %6 = load %struct.CObject** %object_addr.i, align 4 ; <%struct.CObject*> [#uses=1] + %7 = icmp ne %struct.CObject* %6, null ; [#uses=1] + br i1 %7, label %bb.i, label %_Z13ReleaseObjectP7CObject.exit + +bb.i: ; preds = %entry + call void @llvm.dbg.stoppoint(i32 12, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) nounwind + %8 = load %struct.CObject** %object_addr.i, align 4 ; <%struct.CObject*> [#uses=1] + call void @_ZN7CObject7releaseEv(%struct.CObject* %8) nounwind + br label %_Z13ReleaseObjectP7CObject.exit + +_Z13ReleaseObjectP7CObject.exit: ; preds = %bb.i, %entry + call void @llvm.dbg.stoppoint(i32 13, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) nounwind + store %struct.CObject* null, %struct.CObject** %0, align 4 + %9 = load %struct.CObject** %0, align 4 ; <%struct.CObject*> [#uses=1] + store %struct.CObject* %9, %struct.CObject** %retval.i, align 4 + %retval2.i = load %struct.CObject** %retval.i ; <%struct.CObject*> [#uses=0] + call void @llvm.dbg.stoppoint(i32 13, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) nounwind + call void @llvm.dbg.stoppoint(i32 27, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram28 to { }*)) + br label %bb + +bb: ; preds = %_Z13ReleaseObjectP7CObject.exit + call void @llvm.dbg.stoppoint(i32 27, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) + br label %return + +return: ; preds = %bb + call void @llvm.dbg.stoppoint(i32 27, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit4 to { }*)) + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram54 to { }*)) + ret void +} + +define i32 @main() ssp { +entry: + %retval = alloca i32 ; [#uses=2] + %C = alloca %struct.AAAAAImageParser* ; <%struct.AAAAAImageParser**> [#uses=3] + %0 = alloca i32 ; [#uses=2] + %C.1 = alloca %struct.AAAAAImageParser* ; <%struct.AAAAAImageParser**> [#uses=4] + %1 = alloca %struct.AAAAAImageParser* ; <%struct.AAAAAImageParser**> [#uses=3] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram59 to { }*)) + %2 = bitcast %struct.AAAAAImageParser** %C to { }* ; <{ }*> [#uses=1] + call void @llvm.dbg.declare({ }* %2, { }* bitcast (%llvm.dbg.variable.type* @llvm.dbg.variable61 to { }*)) + call void @llvm.dbg.stoppoint(i32 4, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %3 = call i8* @_Znwm(i32 4) ; [#uses=1] + %4 = bitcast i8* %3 to %struct.AAAAAImageParser* ; <%struct.AAAAAImageParser*> [#uses=1] + store %struct.AAAAAImageParser* %4, %struct.AAAAAImageParser** %1, align 4 + %5 = load %struct.AAAAAImageParser** %1, align 4 ; <%struct.AAAAAImageParser*> [#uses=1] + %6 = getelementptr %struct.AAAAAImageParser* %5, i32 0, i32 0 ; <%struct.CObject**> [#uses=1] + %7 = load %struct.CObject** getelementptr (%struct.AAAAAImageParser* @_ZZ4mainE3C.0, i32 0, i32 0), align 4 ; <%struct.CObject*> [#uses=1] + store %struct.CObject* %7, %struct.CObject** %6, align 4 + %8 = load %struct.AAAAAImageParser** %1, align 4 ; <%struct.AAAAAImageParser*> [#uses=1] + store %struct.AAAAAImageParser* %8, %struct.AAAAAImageParser** %C, align 4 + call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %9 = load %struct.AAAAAImageParser** %C, align 4 ; <%struct.AAAAAImageParser*> [#uses=1] + store %struct.AAAAAImageParser* %9, %struct.AAAAAImageParser** %C.1, align 4 + %10 = load %struct.AAAAAImageParser** %C.1, align 4 ; <%struct.AAAAAImageParser*> [#uses=1] + %11 = icmp ne %struct.AAAAAImageParser* %10, null ; [#uses=1] + br i1 %11, label %bb, label %bb1 + ; No predecessors! + call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + br label %bb + +bb: ; preds = %12, %entry + call void @llvm.dbg.stoppoint(i32 5, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + %13 = load %struct.AAAAAImageParser** %C.1, align 4 ; <%struct.AAAAAImageParser*> [#uses=1] + call void @_ZN16AAAAAImageParserD1Ev(%struct.AAAAAImageParser* %13) nounwind + %14 = load %struct.AAAAAImageParser** %C.1, align 4 ; <%struct.AAAAAImageParser*> [#uses=1] + %15 = bitcast %struct.AAAAAImageParser* %14 to i8* ; [#uses=1] + call void @_ZdlPv(i8* %15) nounwind + br label %bb1 + +bb1: ; preds = %bb, %entry + call void @llvm.dbg.stoppoint(i32 6, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + store i32 0, i32* %0, align 4 + %16 = load i32* %0, align 4 ; [#uses=1] + store i32 %16, i32* %retval, align 4 + br label %return + +return: ; preds = %bb1 + %retval2 = load i32* %retval ; [#uses=1] + call void @llvm.dbg.stoppoint(i32 6, i32 0, { }* bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit to { }*)) + call void @llvm.dbg.region.end({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram59 to { }*)) + ret i32 %retval2 +} + +declare i8* @_Znwm(i32) + +declare void @_ZdlPv(i8*) nounwind From isanbard at gmail.com Mon Jun 15 23:02:04 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 16 Jun 2009 04:02:04 -0000 Subject: [llvm-commits] [llvm] r73464 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Message-ID: <200906160402.n5G424Ws022314@zion.cs.uiuc.edu> Author: void Date: Mon Jun 15 23:02:03 2009 New Revision: 73464 URL: http://llvm.org/viewvc/llvm-project?rev=73464&view=rev Log: Fix typos. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp?rev=73464&r1=73463&r2=73464&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Mon Jun 15 23:02:03 2009 @@ -190,7 +190,7 @@ Asm->EmitULEB128Bytes(Offset); Asm->EOL("Offset"); } else { - assert(0 && "Machine move no supported yet."); + assert(0 && "Machine move not supported yet."); } } else if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) { @@ -200,7 +200,7 @@ Asm->EmitULEB128Bytes(RI->getDwarfRegNum(Dst.getReg(), isEH)); Asm->EOL("Register"); } else { - assert(0 && "Machine move no supported yet."); + assert(0 && "Machine move not supported yet."); } } else { unsigned Reg = RI->getDwarfRegNum(Src.getReg(), isEH); From isanbard at gmail.com Mon Jun 15 23:06:16 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 16 Jun 2009 04:06:16 -0000 Subject: [llvm-commits] [llvm] r73465 - /llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200906160406.n5G46GYg022486@zion.cs.uiuc.edu> Author: void Date: Mon Jun 15 23:06:15 2009 New Revision: 73465 URL: http://llvm.org/viewvc/llvm-project?rev=73465&view=rev Log: The DWARF to compact encoding converter assumes that the DW_CFA_def_cfa_offset comes after the DW_CFA_def_cfa_register, because the CFA is really ESP from the start of the function and only gets an offset when the "subl $xxx,%esp" instruction happens, not the other way around. And reapply r72898: The DWARF unwind info was incorrect. While compiling with `-fomit-frame-pointer', we would lack the DW_CFA_advance_loc information for a lot of function, and then they would be `0'. The linker (at least on Darwin) needs to encode the stack size. In some cases, the stack size is too large to directly encode. So the linker checks to see if there is a "subl $xxx,%esp" instruction at the point where the `DW_CFA_def_cfa_offset' says the pc was. If so, the compact encoding records the offset in the function to where the stack size is embedded. But because the `DW_CFA_advance_loc' instructions are missing, it looks before the function and dies. So, instead of emitting the EH debug label before the stack adjustment operations, emit it afterwards, right before the frame move stuff. Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=73465&r1=73464&r2=73465&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Mon Jun 15 23:06:15 2009 @@ -662,6 +662,17 @@ TargetFrameInfo::StackGrowsUp ? TD->getPointerSize() : -TD->getPointerSize()); + if (hasFP(MF)) { + // Save FP + MachineLocation FPDst(MachineLocation::VirtualFP, 2*stackGrowth); + MachineLocation FPSrc(FramePtr); + Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); + } + + MachineLocation FPDst(hasFP(MF) ? FramePtr : StackPtr); + MachineLocation FPSrc(MachineLocation::VirtualFP); + Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); + if (StackSize) { // Show update of SP. if (hasFP(MF)) { @@ -676,7 +687,7 @@ Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); } } else { - //FIXME: Verify & implement for FP + // FIXME: Verify & implement for FP MachineLocation SPDst(StackPtr); MachineLocation SPSrc(StackPtr, stackGrowth); Moves.push_back(MachineMove(FrameLabelId, SPDst, SPSrc)); @@ -704,17 +715,6 @@ MachineLocation CSSrc(Reg); Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc)); } - - if (hasFP(MF)) { - // Save FP - MachineLocation FPDst(MachineLocation::VirtualFP, 2*stackGrowth); - MachineLocation FPSrc(FramePtr); - Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); - } - - MachineLocation FPDst(hasFP(MF) ? FramePtr : StackPtr); - MachineLocation FPSrc(MachineLocation::VirtualFP); - Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); } @@ -822,13 +822,6 @@ NumBytes = StackSize - X86FI->getCalleeSavedFrameSize(); } - unsigned ReadyLabelId = 0; - if (needsFrameMoves) { - // Mark effective beginning of when frame pointer is ready. - ReadyLabelId = MMI->NextLabelID(); - BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(ReadyLabelId); - } - // Skip the callee-saved push instructions. while (MBBI != MBB.end() && (MBBI->getOpcode() == X86::PUSH32r || @@ -891,8 +884,13 @@ emitSPUpdate(MBB, MBBI, StackPtr, -(int64_t)NumBytes, Is64Bit, TII); } - if (needsFrameMoves) + if (needsFrameMoves) { + unsigned ReadyLabelId = 0; + // Mark effective beginning of when frame pointer is ready. + ReadyLabelId = MMI->NextLabelID(); + BuildMI(MBB, MBBI, DL, TII.get(X86::DBG_LABEL)).addImm(ReadyLabelId); emitFrameMoves(MF, FrameLabelId, ReadyLabelId); + } } void X86RegisterInfo::emitEpilogue(MachineFunction &MF, From isanbard at gmail.com Mon Jun 15 23:12:45 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 16 Jun 2009 04:12:45 -0000 Subject: [llvm-commits] [llvm] r73468 - /llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200906160412.n5G4Cjaj022742@zion.cs.uiuc.edu> Author: void Date: Mon Jun 15 23:12:45 2009 New Revision: 73468 URL: http://llvm.org/viewvc/llvm-project?rev=73468&view=rev Log: There doesn't seem to be a reason to move the save FP stuff. Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=73468&r1=73467&r2=73468&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Mon Jun 15 23:12:45 2009 @@ -662,13 +662,6 @@ TargetFrameInfo::StackGrowsUp ? TD->getPointerSize() : -TD->getPointerSize()); - if (hasFP(MF)) { - // Save FP - MachineLocation FPDst(MachineLocation::VirtualFP, 2*stackGrowth); - MachineLocation FPSrc(FramePtr); - Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); - } - MachineLocation FPDst(hasFP(MF) ? FramePtr : StackPtr); MachineLocation FPSrc(MachineLocation::VirtualFP); Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); @@ -715,6 +708,13 @@ MachineLocation CSSrc(Reg); Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc)); } + + if (hasFP(MF)) { + // Save FP + MachineLocation FPDst(MachineLocation::VirtualFP, 2*stackGrowth); + MachineLocation FPSrc(FramePtr); + Moves.push_back(MachineMove(ReadyLabelId, FPDst, FPSrc)); + } } From sabre at nondot.org Tue Jun 16 00:15:24 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 05:15:24 -0000 Subject: [llvm-commits] [llvm] r73470 - /llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Message-ID: <200906160515.n5G5FOJK024676@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 00:15:21 2009 New Revision: 73470 URL: http://llvm.org/viewvc/llvm-project?rev=73470&view=rev Log: Fix PR4336: Iterating over use-def chains doesn't seem to be deterministic. The problem was that BitcodeReader::materializeModule would read functions from the bc file in densemap pointer key order (doubly non-deterministic!), which would cause the use-def chains to be set up for globals in non-determinstic order. Non-determinstic use/def chains can cause nondeterminism in many places down-stream. Many thanks to Julien Lerouge for putting together the pass in the PR that shows the issue! Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=73470&r1=73469&r2=73470&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jun 16 00:15:21 2009 @@ -2040,14 +2040,13 @@ Module *BitcodeReader::materializeModule(std::string *ErrInfo) { - for (DenseMap >::iterator I = - DeferredFunctionInfo.begin(), E = DeferredFunctionInfo.end(); I != E; - ++I) { - Function *F = I->first; + // Iterate over the module, deserializing any functions that are still on + // disk. + for (Module::iterator F = TheModule->begin(), E = TheModule->end(); + F != E; ++F) if (F->hasNotBeenReadFromBitcode() && materializeFunction(F, ErrInfo)) return 0; - } // Upgrade any intrinsic calls that slipped through (should not happen!) and // delete the old functions to clean up. We can't do this unless the entire @@ -2123,7 +2122,7 @@ // is run. if (M) M = R->releaseModule(ErrMsg); - + delete R; return M; } From baldrick at free.fr Tue Jun 16 01:10:37 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Jun 2009 08:10:37 +0200 Subject: [llvm-commits] [llvm] r73421 - /llvm/trunk/docs/LangRef.html In-Reply-To: <200906152118.n5FLI25H008675@zion.cs.uiuc.edu> References: <200906152118.n5FLI25H008675@zion.cs.uiuc.edu> Message-ID: <4A37375D.3070406@free.fr> Hi Dan, >
    noredzone
    >
    This attribute indicates that the code generator should not use a > -red zone, even if it would otherwise be supported by the target-specific ABI. > +red zone, even if the target-specific ABI normally permits it. >
    thanks for changing it. Just to be totally annoying: how about dropping "normally". The ABI still permits a redzone whether you have noredzone or not. Ciao, Duncan. From sabre at nondot.org Tue Jun 16 01:11:36 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 06:11:36 -0000 Subject: [llvm-commits] [llvm] r73471 - /llvm/trunk/lib/Target/X86/README.txt Message-ID: <200906160611.n5G6BapW026509@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 01:11:35 2009 New Revision: 73471 URL: http://llvm.org/viewvc/llvm-project?rev=73471&view=rev Log: I think instcombine should unconditionally do this xform. 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=73471&r1=73470&r2=73471&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README.txt (original) +++ llvm/trunk/lib/Target/X86/README.txt Tue Jun 16 01:11:35 2009 @@ -1858,8 +1858,23 @@ setne %al ret -We could do this transformation in instcombine, but it's only clearly -beneficial on platforms with a test instruction. +This should definitely be done in instcombine, canonicalizing the range +condition into a != condition. We get this IR: + +define i32 @a(i32 %x) nounwind readnone { +entry: + %0 = and i32 %x, 127 ; [#uses=1] + %1 = icmp ugt i32 %0, 31 ; [#uses=1] + %2 = zext i1 %1 to i32 ; [#uses=1] + ret i32 %2 +} + +Instcombine prefers to strength reduce relational comparisons to equality +comparisons when possible, this should be another case of that. This could +be handled pretty easily in InstCombiner::visitICmpInstWithInstAndIntCst, but it +looks like InstCombiner::visitICmpInstWithInstAndIntCst should really already +be redesigned to use ComputeMaskedBits and friends. + //===---------------------------------------------------------------------===// Testcase: From sabre at nondot.org Tue Jun 16 01:15:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 06:15:58 -0000 Subject: [llvm-commits] [llvm] r73472 - /llvm/trunk/lib/Target/X86/README.txt Message-ID: <200906160615.n5G6Fx1J026629@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 01:15:56 2009 New Revision: 73472 URL: http://llvm.org/viewvc/llvm-project?rev=73472&view=rev Log: another xform that is target-independent (should be done in instcombine). 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=73472&r1=73471&r2=73472&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README.txt (original) +++ llvm/trunk/lib/Target/X86/README.txt Tue Jun 16 01:15:56 2009 @@ -1895,20 +1895,40 @@ Testcase: int x(int a) { return (a & 0x80) ? 0x100 : 0; } +int y(int a) { return (a & 0x80) *2; } -Current output: +Current: testl $128, 4(%esp) setne %al movzbl %al, %eax shll $8, %eax ret -Ideal output: +Better: movl 4(%esp), %eax addl %eax, %eax andl $256, %eax ret -We generally want to fold shifted tests of a single bit into a shift+and on x86. +This is another general instcombine transformation that is profitable on all +targets. In LLVM IR, these functions look like this: + +define i32 @x(i32 %a) nounwind readnone { +entry: + %0 = and i32 %a, 128 + %1 = icmp eq i32 %0, 0 + %iftmp.0.0 = select i1 %1, i32 0, i32 256 + ret i32 %iftmp.0.0 +} + +define i32 @y(i32 %a) nounwind readnone { +entry: + %0 = shl i32 %a, 1 + %1 = and i32 %0, 256 + ret i32 %1 +} + +Replacing an icmp+select with a shift should always be considered profitable in +instcombine. //===---------------------------------------------------------------------===// From isanbard at gmail.com Tue Jun 16 01:18:11 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 16 Jun 2009 06:18:11 -0000 Subject: [llvm-commits] [llvm] r73473 - /llvm/tags/Apple/llvmCore-2113/ Message-ID: <200906160618.n5G6IBSP026717@zion.cs.uiuc.edu> Author: void Date: Tue Jun 16 01:18:11 2009 New Revision: 73473 URL: http://llvm.org/viewvc/llvm-project?rev=73473&view=rev Log: Creating llvmCore-2113 branch Added: llvm/tags/Apple/llvmCore-2113/ - copied from r73472, llvm/branches/Apple/Bender/ From isanbard at gmail.com Tue Jun 16 01:18:25 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 16 Jun 2009 06:18:25 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73475 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2113/ Message-ID: <200906160618.n5G6IPaK026746@zion.cs.uiuc.edu> Author: void Date: Tue Jun 16 01:18:25 2009 New Revision: 73475 URL: http://llvm.org/viewvc/llvm-project?rev=73475&view=rev Log: Creating llvmgcc42-2113 branch Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2113/ - copied from r73473, llvm-gcc-4.2/branches/Apple/Bender/ From baldrick at free.fr Tue Jun 16 01:26:21 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Jun 2009 08:26:21 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r73439 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <200906152305.n5FN5w97012380@zion.cs.uiuc.edu> References: <200906152305.n5FN5w97012380@zion.cs.uiuc.edu> Message-ID: <4A373B0D.8070405@free.fr> Hi Dan, > @@ -3089,6 +3104,8 @@ > Value *TreeToLLVM::EmitNEGATE_EXPR(tree exp, const MemRef *DestLoc) { > if (!DestLoc) { > Value *V = Emit(TREE_OPERAND(exp, 0), 0); > + if (V->getType()->isFPOrFPVector()) > + return Builder.CreateFNeg(V); > if (!isa(V->getType())) > return Builder.CreateNeg(V); you could also add a CreateAnyNeg builder method that dispatches to CreateFNeg/CreateNeg appropriately (and likewise for other operations) to handle this kind of thing. Not sure if this is really a good idea, but it did strike me that other language front-ends might find this helpful. Ciao, Duncan. From sabre at nondot.org Tue Jun 16 01:32:52 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 01:32:52 -0500 Subject: [llvm-commits] CVS: llvm-www/OpenProjects.html Message-ID: <200906160632.n5G6Wqu2027226@zion.cs.uiuc.edu> Changes in directory llvm-www: OpenProjects.html updated: 1.50 -> 1.51 --- Log message: add a note --- Diffs of the changes: (+3 -1) OpenProjects.html | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm-www/OpenProjects.html diff -u llvm-www/OpenProjects.html:1.50 llvm-www/OpenProjects.html:1.51 --- llvm-www/OpenProjects.html:1.50 Wed Mar 25 12:27:33 2009 +++ llvm-www/OpenProjects.html Tue Jun 16 01:31:47 2009 @@ -396,6 +396,8 @@
  • Type inference (aka. devirtualization)
  • +
  • Value + assertions (also PR810).
  • @@ -507,7 +509,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"> LLVM Compiler Infrastructure
    - Last modified: $Date: 2009/03/25 17:27:33 $ + Last modified: $Date: 2009/06/16 06:31:47 $ From eli.friedman at gmail.com Tue Jun 16 01:41:00 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 16 Jun 2009 06:41:00 -0000 Subject: [llvm-commits] [llvm] r73476 - in /llvm/trunk/lib/Target: CellSPU/SPUISelLowering.cpp IA64/IA64ISelLowering.cpp Mips/MipsISelLowering.cpp X86/X86ISelLowering.cpp Message-ID: <200906160641.n5G6f0ii027457@zion.cs.uiuc.edu> Author: efriedma Date: Tue Jun 16 01:40:59 2009 New Revision: 73476 URL: http://llvm.org/viewvc/llvm-project?rev=73476&view=rev Log: Misc accumulated tweaks to legalization logic for various targets. Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=73476&r1=73475&r2=73476&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Tue Jun 16 01:40:59 2009 @@ -249,6 +249,25 @@ setOperationAction(ISD::MUL, MVT::i32, Legal); setOperationAction(ISD::MUL, MVT::i64, Legal); + // Expand double-width multiplication + // FIXME: It would probably be reasonable to support some of these operations + setOperationAction(ISD::UMUL_LOHI, MVT::i8, Expand); + setOperationAction(ISD::SMUL_LOHI, MVT::i8, Expand); + setOperationAction(ISD::MULHU, MVT::i8, Expand); + setOperationAction(ISD::MULHS, MVT::i8, Expand); + setOperationAction(ISD::UMUL_LOHI, MVT::i16, Expand); + setOperationAction(ISD::SMUL_LOHI, MVT::i16, Expand); + setOperationAction(ISD::MULHU, MVT::i16, Expand); + setOperationAction(ISD::MULHS, MVT::i16, Expand); + setOperationAction(ISD::UMUL_LOHI, MVT::i32, Expand); + setOperationAction(ISD::SMUL_LOHI, MVT::i32, Expand); + setOperationAction(ISD::MULHU, MVT::i32, Expand); + setOperationAction(ISD::MULHS, MVT::i32, Expand); + setOperationAction(ISD::UMUL_LOHI, MVT::i64, Expand); + setOperationAction(ISD::SMUL_LOHI, MVT::i64, Expand); + setOperationAction(ISD::MULHU, MVT::i64, Expand); + setOperationAction(ISD::MULHS, MVT::i64, Expand); + // Need to custom handle (some) common i8, i64 math ops setOperationAction(ISD::ADD, MVT::i8, Custom); setOperationAction(ISD::ADD, MVT::i64, Legal); Modified: llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp?rev=73476&r1=73475&r2=73476&view=diff ============================================================================== --- llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/IA64/IA64ISelLowering.cpp Tue Jun 16 01:40:59 2009 @@ -107,6 +107,10 @@ // VASTART needs to be custom lowered to use the VarArgsFrameIndex setOperationAction(ISD::VAARG , MVT::Other, Custom); setOperationAction(ISD::VASTART , MVT::Other, Custom); + + // FIXME: These should be legal + setOperationAction(ISD::BIT_CONVERT, MVT::i64, Expand); + setOperationAction(ISD::BIT_CONVERT, MVT::f64, Expand); // Use the default implementation. setOperationAction(ISD::VACOPY , MVT::Other, Expand); Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=73476&r1=73475&r2=73476&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Tue Jun 16 01:40:59 2009 @@ -95,6 +95,7 @@ setOperationAction(ISD::JumpTable, MVT::i32, Custom); setOperationAction(ISD::ConstantPool, MVT::i32, Custom); setOperationAction(ISD::SELECT, MVT::f32, Custom); + setOperationAction(ISD::SELECT, MVT::f64, Custom); setOperationAction(ISD::SELECT, MVT::i32, Custom); setOperationAction(ISD::SETCC, MVT::f32, Custom); setOperationAction(ISD::SETCC, MVT::f64, Custom); @@ -122,6 +123,7 @@ setOperationAction(ISD::SRA_PARTS, MVT::i32, Expand); setOperationAction(ISD::SRL_PARTS, MVT::i32, Expand); setOperationAction(ISD::FCOPYSIGN, MVT::f32, Expand); + setOperationAction(ISD::FCOPYSIGN, MVT::f64, Expand); // We don't have line number support yet. setOperationAction(ISD::DBG_STOPPOINT, MVT::Other, Expand); Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=73476&r1=73475&r2=73476&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Jun 16 01:40:59 2009 @@ -788,8 +788,6 @@ setOperationAction(ISD::USUBO, MVT::i64, Custom); setOperationAction(ISD::SMULO, MVT::i32, Custom); setOperationAction(ISD::SMULO, MVT::i64, Custom); - setOperationAction(ISD::UMULO, MVT::i32, Custom); - setOperationAction(ISD::UMULO, MVT::i64, Custom); if (!Subtarget->is64Bit()) { // These libcalls are not available in 32-bit. From eli.friedman at gmail.com Tue Jun 16 01:58:29 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 16 Jun 2009 06:58:29 -0000 Subject: [llvm-commits] [llvm] r73477 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp test/CodeGen/CellSPU/mul-with-overflow.ll test/CodeGen/PowerPC/mul-with-overflow.ll test/CodeGen/X86/umul-with-overflow.ll Message-ID: <200906160658.n5G6wT6x027997@zion.cs.uiuc.edu> Author: efriedma Date: Tue Jun 16 01:58:29 2009 New Revision: 73477 URL: http://llvm.org/viewvc/llvm-project?rev=73477&view=rev Log: Add some generic expansion logic for SMULO and UMULO. Fixes UMULO support for x86, and UMULO/SMULO for many architectures, including PPC (PR4201), ARM, and Cell. The resulting expansion isn't perfect, but it's not bad. Added: llvm/trunk/test/CodeGen/CellSPU/mul-with-overflow.ll llvm/trunk/test/CodeGen/PowerPC/mul-with-overflow.ll llvm/trunk/test/CodeGen/X86/umul-with-overflow.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=73477&r1=73476&r2=73477&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Jun 16 01:58:29 2009 @@ -2768,6 +2768,53 @@ ISD::SETULT : ISD::SETUGT)); break; } + case ISD::UMULO: + case ISD::SMULO: { + MVT VT = Node->getValueType(0); + SDValue LHS = Node->getOperand(0); + SDValue RHS = Node->getOperand(1); + SDValue BottomHalf; + SDValue TopHalf; + static unsigned Ops[2][3] = + { { ISD::MULHU, ISD::UMUL_LOHI, ISD::ZERO_EXTEND }, + { ISD::MULHS, ISD::SMUL_LOHI, ISD::SIGN_EXTEND }}; + bool isSigned = Node->getOpcode() == ISD::SMULO; + if (TLI.isOperationLegalOrCustom(Ops[isSigned][0], VT)) { + BottomHalf = DAG.getNode(ISD::MUL, dl, VT, LHS, RHS); + TopHalf = DAG.getNode(Ops[isSigned][0], dl, VT, LHS, RHS); + } else if (TLI.isOperationLegalOrCustom(Ops[isSigned][1], VT)) { + BottomHalf = DAG.getNode(Ops[isSigned][1], dl, DAG.getVTList(VT, VT), LHS, + RHS); + TopHalf = BottomHalf.getValue(1); + } else if (TLI.isTypeLegal(MVT::getIntegerVT(VT.getSizeInBits() * 2))) { + MVT WideVT = MVT::getIntegerVT(VT.getSizeInBits() * 2); + LHS = DAG.getNode(Ops[isSigned][2], dl, WideVT, LHS); + RHS = DAG.getNode(Ops[isSigned][2], dl, WideVT, RHS); + Tmp1 = DAG.getNode(ISD::MUL, dl, WideVT, LHS, RHS); + BottomHalf = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, VT, Tmp1, + DAG.getIntPtrConstant(0)); + TopHalf = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, VT, Tmp1, + DAG.getIntPtrConstant(1)); + } else { + // FIXME: We should be able to fall back to a libcall with an illegal + // type in some cases cases. + // Also, we can fall back to a division in some cases, but that's a big + // performance hit in the general case. + assert(0 && "Don't know how to expand this operation yet!"); + } + if (isSigned) { + Tmp1 = DAG.getConstant(VT.getSizeInBits() - 1, TLI.getShiftAmountTy()); + Tmp1 = DAG.getNode(ISD::SRA, dl, VT, BottomHalf, Tmp1); + TopHalf = DAG.getSetCC(dl, TLI.getSetCCResultType(VT), TopHalf, Tmp1, + ISD::SETNE); + } else { + TopHalf = DAG.getSetCC(dl, TLI.getSetCCResultType(VT), TopHalf, + DAG.getConstant(0, VT), ISD::SETNE); + } + Results.push_back(BottomHalf); + Results.push_back(TopHalf); + break; + } case ISD::BUILD_PAIR: { MVT PairTy = Node->getValueType(0); Tmp1 = DAG.getNode(ISD::ZERO_EXTEND, dl, PairTy, Node->getOperand(0)); Added: llvm/trunk/test/CodeGen/CellSPU/mul-with-overflow.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CellSPU/mul-with-overflow.ll?rev=73477&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/CellSPU/mul-with-overflow.ll (added) +++ llvm/trunk/test/CodeGen/CellSPU/mul-with-overflow.ll Tue Jun 16 01:58:29 2009 @@ -0,0 +1,15 @@ +; RUN: llvm-as < %s | llc -march=cellspu + +declare {i16, i1} @llvm.smul.with.overflow.i16(i16 %a, i16 %b) +define i1 @a(i16 %x) zeroext nounwind { + %res = call {i16, i1} @llvm.smul.with.overflow.i16(i16 %x, i16 3) + %obil = extractvalue {i16, i1} %res, 1 + ret i1 %obil +} + +declare {i16, i1} @llvm.umul.with.overflow.i16(i16 %a, i16 %b) +define i1 @b(i16 %x) zeroext nounwind { + %res = call {i16, i1} @llvm.umul.with.overflow.i16(i16 %x, i16 3) + %obil = extractvalue {i16, i1} %res, 1 + ret i1 %obil +} Added: llvm/trunk/test/CodeGen/PowerPC/mul-with-overflow.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/mul-with-overflow.ll?rev=73477&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/mul-with-overflow.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/mul-with-overflow.ll Tue Jun 16 01:58:29 2009 @@ -0,0 +1,15 @@ +; RUN: llvm-as < %s | llc -march=ppc32 + +declare {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b) +define i1 @a(i32 %x) zeroext nounwind { + %res = call {i32, i1} @llvm.umul.with.overflow.i32(i32 %x, i32 3) + %obil = extractvalue {i32, i1} %res, 1 + ret i1 %obil +} + +declare {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b) +define i1 @b(i32 %x) zeroext nounwind { + %res = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %x, i32 3) + %obil = extractvalue {i32, i1} %res, 1 + ret i1 %obil +} Added: llvm/trunk/test/CodeGen/X86/umul-with-overflow.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/umul-with-overflow.ll?rev=73477&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/umul-with-overflow.ll (added) +++ llvm/trunk/test/CodeGen/X86/umul-with-overflow.ll Tue Jun 16 01:58:29 2009 @@ -0,0 +1,8 @@ +; RUN: llvm-as < %s | llc -march=x86 | grep "\\\\\\\ Author: evancheng Date: Tue Jun 16 02:12:58 2009 New Revision: 73478 URL: http://llvm.org/viewvc/llvm-project?rev=73478&view=rev Log: If a val# is defined by an implicit_def and it is being removed, all of the copies off the val# were removed. This causes problem later since the scavenger will see uses of registers without defs. The proper solution is to change the copies into implicit_def's instead. TurnCopyIntoImpDef turns a copy into implicit_def and remove the val# defined by it. This causes an scavenger assertion later if the def reaches other blocks. Disable the transformation if the value live interval extends beyond its def block. Added: llvm/trunk/test/CodeGen/ARM/2009-06-15-RegScavengerAssert.ll Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=73478&r1=73477&r2=73478&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Tue Jun 16 02:12:58 2009 @@ -616,19 +616,17 @@ } MachineBasicBlock::iterator MII = next(MachineBasicBlock::iterator(CopyMI)); - CopyMI->removeFromParent(); tii_->reMaterialize(*MBB, MII, DstReg, DefMI); MachineInstr *NewMI = prior(MII); if (checkForDeadDef) { - // PR4090 fix: Trim interval failed because there was no use of the - // source interval in this MBB. If the def is in this MBB too then we - // should mark it dead: - if (DefMI->getParent() == MBB) { - DefMI->addRegisterDead(SrcInt.reg, tri_); - SrcLR->end = SrcLR->start + 1; - } - + // PR4090 fix: Trim interval failed because there was no use of the + // source interval in this MBB. If the def is in this MBB too then we + // should mark it dead: + if (DefMI->getParent() == MBB) { + DefMI->addRegisterDead(SrcInt.reg, tri_); + SrcLR->end = SrcLR->start + 1; + } } // CopyMI may have implicit operands, transfer them over to the newly @@ -647,7 +645,7 @@ } li_->ReplaceMachineInstrInMaps(CopyMI, NewMI); - MBB->getParent()->DeleteMachineInstr(CopyMI); + CopyMI->eraseFromParent(); ReMatCopies.insert(CopyMI); ReMatDefs.insert(DefMI); ++NumReMats; @@ -967,7 +965,7 @@ /// RemoveCopiesFromValNo - The specified value# is defined by an implicit /// def and it is being removed. Turn all copies from this value# into -/// identity copies so they will be removed. +/// implicit_defs. void SimpleRegisterCoalescing::RemoveCopiesFromValNo(LiveInterval &li, VNInfo *VNI) { SmallVector ImpDefs; @@ -979,9 +977,8 @@ MachineInstr *MI = &*RI; ++RI; if (MO->isDef()) { - if (MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF) { + if (MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF) ImpDefs.push_back(MI); - } continue; } if (JoinedCopies.count(MI)) @@ -994,13 +991,18 @@ unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx; if (tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) && SrcReg == li.reg) { - // Each use MI may have multiple uses of this register. Change them all. - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand &MO = MI->getOperand(i); - if (MO.isReg() && MO.getReg() == li.reg) - MO.setReg(DstReg); - } - JoinedCopies.insert(MI); + // Change it to an implicit_def. + MI->setDesc(tii_->get(TargetInstrInfo::IMPLICIT_DEF)); + for (int i = MI->getNumOperands() - 1, e = 0; i > e; --i) + MI->RemoveOperand(i); + // It's no longer a copy, update the valno it defines. + unsigned DefIdx = li_->getDefIndex(UseIdx); + LiveInterval &DstInt = li_->getInterval(DstReg); + LiveInterval::iterator DLR = DstInt.FindLiveRangeContaining(DefIdx); + assert(DLR != DstInt.end() && "Live range not found!"); + assert(DLR->valno->copy == MI); + DLR->valno->copy = NULL; + ReMatCopies.insert(MI); } else if (UseIdx > LastUseIdx) { LastUseIdx = UseIdx; LastUse = MO; @@ -2641,6 +2643,11 @@ return false; LiveInterval &DstInt = li_->getInterval(DstReg); const LiveRange *DstLR = DstInt.getLiveRangeContaining(CopyIdx); + // If the valno extends beyond this basic block, then it's not safe to delete + // the val# or else livein information won't be correct. + MachineBasicBlock *EndMBB = li_->getMBBFromIndex(DstLR->end); + if (EndMBB != MBB) + return false; DstInt.removeValNo(DstLR->valno); CopyMI->setDesc(tii_->get(TargetInstrInfo::IMPLICIT_DEF)); for (int i = CopyMI->getNumOperands() - 1, e = 0; i > e; --i) Added: llvm/trunk/test/CodeGen/ARM/2009-06-15-RegScavengerAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-06-15-RegScavengerAssert.ll?rev=73478&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-06-15-RegScavengerAssert.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-06-15-RegScavengerAssert.ll Tue Jun 16 02:12:58 2009 @@ -0,0 +1,344 @@ +; RUN: llvm-as < %s | llc -mtriple=armv6-apple-darwin + + %struct.term = type { i32, i32, i32 } + +declare fastcc i8* @memory_Malloc(i32) nounwind + +define fastcc %struct.term* @t1() nounwind { +entry: + br i1 undef, label %bb, label %bb1 + +bb: ; preds = %entry + ret %struct.term* undef + +bb1: ; preds = %entry + %0 = tail call fastcc i8* @memory_Malloc(i32 12) nounwind ; [#uses=0] + %1 = tail call fastcc i8* @memory_Malloc(i32 12) nounwind ; [#uses=0] + ret %struct.term* undef +} + + +define i32 @t2(i32 %argc, i8** nocapture %argv) nounwind { +entry: + br label %bb6.i8 + +bb6.i8: ; preds = %memory_CalculateRealBlockSize1374.exit.i, %entry + br i1 undef, label %memory_CalculateRealBlockSize1374.exit.i, label %bb.i.i9 + +bb.i.i9: ; preds = %bb6.i8 + br label %memory_CalculateRealBlockSize1374.exit.i + +memory_CalculateRealBlockSize1374.exit.i: ; preds = %bb.i.i9, %bb6.i8 + %0 = phi i32 [ undef, %bb.i.i9 ], [ undef, %bb6.i8 ] ; [#uses=2] + store i32 %0, i32* undef, align 4 + %1 = urem i32 8184, %0 ; [#uses=1] + %2 = sub i32 8188, %1 ; [#uses=1] + store i32 %2, i32* undef, align 4 + br i1 undef, label %memory_Init.exit, label %bb6.i8 + +memory_Init.exit: ; preds = %memory_CalculateRealBlockSize1374.exit.i + br label %bb.i.i + +bb.i.i: ; preds = %bb.i.i, %memory_Init.exit + br i1 undef, label %symbol_Init.exit, label %bb.i.i + +symbol_Init.exit: ; preds = %bb.i.i + br label %bb.i.i67 + +bb.i.i67: ; preds = %bb.i.i67, %symbol_Init.exit + br i1 undef, label %symbol_CreatePrecedence3522.exit, label %bb.i.i67 + +symbol_CreatePrecedence3522.exit: ; preds = %bb.i.i67 + br label %bb.i.i8.i + +bb.i.i8.i: ; preds = %bb.i.i8.i, %symbol_CreatePrecedence3522.exit + br i1 undef, label %cont_Create.exit9.i, label %bb.i.i8.i + +cont_Create.exit9.i: ; preds = %bb.i.i8.i + br label %bb.i.i.i72 + +bb.i.i.i72: ; preds = %bb.i.i.i72, %cont_Create.exit9.i + br i1 undef, label %cont_Init.exit, label %bb.i.i.i72 + +cont_Init.exit: ; preds = %bb.i.i.i72 + br label %bb.i103 + +bb.i103: ; preds = %bb.i103, %cont_Init.exit + br i1 undef, label %subs_Init.exit, label %bb.i103 + +subs_Init.exit: ; preds = %bb.i103 + br i1 undef, label %bb1.i.i.i80, label %cc_Init.exit + +bb1.i.i.i80: ; preds = %subs_Init.exit + unreachable + +cc_Init.exit: ; preds = %subs_Init.exit + br label %bb.i.i375 + +bb.i.i375: ; preds = %bb.i.i375, %cc_Init.exit + br i1 undef, label %bb.i439, label %bb.i.i375 + +bb.i439: ; preds = %bb.i439, %bb.i.i375 + br i1 undef, label %opts_DeclareSPASSFlagsAsOptions.exit, label %bb.i439 + +opts_DeclareSPASSFlagsAsOptions.exit: ; preds = %bb.i439 + br i1 undef, label %opts_TranslateShortOptDeclarations.exit.i, label %bb.i.i82 + +bb.i.i82: ; preds = %opts_DeclareSPASSFlagsAsOptions.exit + unreachable + +opts_TranslateShortOptDeclarations.exit.i: ; preds = %opts_DeclareSPASSFlagsAsOptions.exit + br i1 undef, label %list_Length.exit.i.thread.i, label %bb.i.i4.i + +list_Length.exit.i.thread.i: ; preds = %opts_TranslateShortOptDeclarations.exit.i + br i1 undef, label %bb18.i.i.i, label %bb26.i.i.i + +bb.i.i4.i: ; preds = %opts_TranslateShortOptDeclarations.exit.i + unreachable + +bb18.i.i.i: ; preds = %list_Length.exit.i.thread.i + unreachable + +bb26.i.i.i: ; preds = %list_Length.exit.i.thread.i + br i1 undef, label %bb27.i142, label %opts_GetOptLongOnly.exit.thread97.i + +opts_GetOptLongOnly.exit.thread97.i: ; preds = %bb26.i.i.i + br label %bb27.i142 + +bb27.i142: ; preds = %opts_GetOptLongOnly.exit.thread97.i, %bb26.i.i.i + br label %bb1.i3.i + +bb1.i3.i: ; preds = %bb1.i3.i, %bb27.i142 + br i1 undef, label %opts_FreeLongOptsArray.exit.i, label %bb1.i3.i + +opts_FreeLongOptsArray.exit.i: ; preds = %bb1.i3.i + br label %bb.i443 + +bb.i443: ; preds = %bb.i443, %opts_FreeLongOptsArray.exit.i + br i1 undef, label %flag_InitStoreByDefaults3542.exit, label %bb.i443 + +flag_InitStoreByDefaults3542.exit: ; preds = %bb.i443 + br i1 undef, label %bb6.i449, label %bb.i503 + +bb6.i449: ; preds = %flag_InitStoreByDefaults3542.exit + unreachable + +bb.i503: ; preds = %bb.i503, %flag_InitStoreByDefaults3542.exit + br i1 undef, label %flag_CleanStore3464.exit, label %bb.i503 + +flag_CleanStore3464.exit: ; preds = %bb.i503 + br i1 undef, label %bb1.i81.i.preheader, label %bb.i173 + +bb.i173: ; preds = %flag_CleanStore3464.exit + unreachable + +bb1.i81.i.preheader: ; preds = %flag_CleanStore3464.exit + br i1 undef, label %bb1.i64.i.preheader, label %bb5.i179 + +bb5.i179: ; preds = %bb1.i81.i.preheader + unreachable + +bb1.i64.i.preheader: ; preds = %bb1.i81.i.preheader + br i1 undef, label %dfg_DeleteProofList.exit.i, label %bb.i9.i + +bb.i9.i: ; preds = %bb1.i64.i.preheader + unreachable + +dfg_DeleteProofList.exit.i: ; preds = %bb1.i64.i.preheader + br i1 undef, label %term_DeleteTermList621.exit.i, label %bb.i.i62.i + +bb.i.i62.i: ; preds = %bb.i.i62.i, %dfg_DeleteProofList.exit.i + br i1 undef, label %term_DeleteTermList621.exit.i, label %bb.i.i62.i + +term_DeleteTermList621.exit.i: ; preds = %bb.i.i62.i, %dfg_DeleteProofList.exit.i + br i1 undef, label %dfg_DFGParser.exit, label %bb.i.i211 + +bb.i.i211: ; preds = %term_DeleteTermList621.exit.i + unreachable + +dfg_DFGParser.exit: ; preds = %term_DeleteTermList621.exit.i + br label %bb.i513 + +bb.i513: ; preds = %bb2.i516, %dfg_DFGParser.exit + br i1 undef, label %bb2.i516, label %bb1.i514 + +bb1.i514: ; preds = %bb.i513 + unreachable + +bb2.i516: ; preds = %bb.i513 + br i1 undef, label %bb.i509, label %bb.i513 + +bb.i509: ; preds = %bb.i509, %bb2.i516 + br i1 undef, label %symbol_TransferPrecedence3468.exit511, label %bb.i509 + +symbol_TransferPrecedence3468.exit511: ; preds = %bb.i509 + br i1 undef, label %bb20, label %bb21 + +bb20: ; preds = %symbol_TransferPrecedence3468.exit511 + unreachable + +bb21: ; preds = %symbol_TransferPrecedence3468.exit511 + br i1 undef, label %cnf_Init.exit, label %bb.i498 + +bb.i498: ; preds = %bb21 + unreachable + +cnf_Init.exit: ; preds = %bb21 + br i1 undef, label %bb23, label %bb22 + +bb22: ; preds = %cnf_Init.exit + br i1 undef, label %bb2.i.i496, label %bb.i.i494 + +bb.i.i494: ; preds = %bb22 + unreachable + +bb2.i.i496: ; preds = %bb22 + unreachable + +bb23: ; preds = %cnf_Init.exit + br i1 undef, label %bb28, label %bb24 + +bb24: ; preds = %bb23 + unreachable + +bb28: ; preds = %bb23 + br i1 undef, label %bb31, label %bb29 + +bb29: ; preds = %bb28 + unreachable + +bb31: ; preds = %bb28 + br i1 undef, label %bb34, label %bb32 + +bb32: ; preds = %bb31 + unreachable + +bb34: ; preds = %bb31 + br i1 undef, label %bb83, label %bb66 + +bb66: ; preds = %bb34 + unreachable + +bb83: ; preds = %bb34 + br i1 undef, label %bb2.i1668, label %bb.i1667 + +bb.i1667: ; preds = %bb83 + unreachable + +bb2.i1668: ; preds = %bb83 + br i1 undef, label %bb5.i205, label %bb3.i204 + +bb3.i204: ; preds = %bb2.i1668 + unreachable + +bb5.i205: ; preds = %bb2.i1668 + br i1 undef, label %bb.i206.i, label %ana_AnalyzeSortStructure.exit.i + +bb.i206.i: ; preds = %bb5.i205 + br i1 undef, label %bb1.i207.i, label %ana_AnalyzeSortStructure.exit.i + +bb1.i207.i: ; preds = %bb.i206.i + br i1 undef, label %bb25.i1801.thread, label %bb.i1688 + +bb.i1688: ; preds = %bb1.i207.i + unreachable + +bb25.i1801.thread: ; preds = %bb1.i207.i + unreachable + +ana_AnalyzeSortStructure.exit.i: ; preds = %bb.i206.i, %bb5.i205 + br i1 undef, label %bb7.i207, label %bb.i1806 + +bb.i1806: ; preds = %ana_AnalyzeSortStructure.exit.i + br i1 undef, label %bb2.i.i.i1811, label %bb.i.i.i1809 + +bb.i.i.i1809: ; preds = %bb.i1806 + unreachable + +bb2.i.i.i1811: ; preds = %bb.i1806 + unreachable + +bb7.i207: ; preds = %ana_AnalyzeSortStructure.exit.i + br i1 undef, label %bb9.i, label %bb8.i + +bb8.i: ; preds = %bb7.i207 + unreachable + +bb9.i: ; preds = %bb7.i207 + br i1 undef, label %bb23.i, label %bb26.i + +bb23.i: ; preds = %bb9.i + br i1 undef, label %bb25.i, label %bb24.i + +bb24.i: ; preds = %bb23.i + br i1 undef, label %sort_SortTheoryIsTrivial.exit.i, label %bb.i2093 + +bb.i2093: ; preds = %bb.i2093, %bb24.i + br label %bb.i2093 + +sort_SortTheoryIsTrivial.exit.i: ; preds = %bb24.i + br i1 undef, label %bb3.i2141, label %bb4.i2143 + +bb3.i2141: ; preds = %sort_SortTheoryIsTrivial.exit.i + unreachable + +bb4.i2143: ; preds = %sort_SortTheoryIsTrivial.exit.i + br i1 undef, label %bb8.i2178, label %bb5.i2144 + +bb5.i2144: ; preds = %bb4.i2143 + br i1 undef, label %bb7.i2177, label %bb1.i28.i + +bb1.i28.i: ; preds = %bb5.i2144 + br i1 undef, label %bb4.i43.i, label %bb2.i.i2153 + +bb2.i.i2153: ; preds = %bb1.i28.i + br i1 undef, label %bb4.i.i33.i, label %bb.i.i30.i + +bb.i.i30.i: ; preds = %bb2.i.i2153 + unreachable + +bb4.i.i33.i: ; preds = %bb2.i.i2153 + br i1 undef, label %bb9.i.i36.i, label %bb5.i.i34.i + +bb5.i.i34.i: ; preds = %bb4.i.i33.i + unreachable + +bb9.i.i36.i: ; preds = %bb4.i.i33.i + br i1 undef, label %bb14.i.i.i2163, label %bb10.i.i37.i + +bb10.i.i37.i: ; preds = %bb9.i.i36.i + unreachable + +bb14.i.i.i2163: ; preds = %bb9.i.i36.i + br i1 undef, label %sort_LinkPrint.exit.i.i, label %bb15.i.i.i2164 + +bb15.i.i.i2164: ; preds = %bb14.i.i.i2163 + unreachable + +sort_LinkPrint.exit.i.i: ; preds = %bb14.i.i.i2163 + unreachable + +bb4.i43.i: ; preds = %bb1.i28.i + unreachable + +bb7.i2177: ; preds = %bb5.i2144 + unreachable + +bb8.i2178: ; preds = %bb4.i2143 + br i1 undef, label %sort_ApproxStaticSortTheory.exit, label %bb.i5.i2185.preheader + +bb.i5.i2185.preheader: ; preds = %bb8.i2178 + br label %bb.i5.i2185 + +bb.i5.i2185: ; preds = %bb.i5.i2185, %bb.i5.i2185.preheader + br i1 undef, label %sort_ApproxStaticSortTheory.exit, label %bb.i5.i2185 + +sort_ApproxStaticSortTheory.exit: ; preds = %bb.i5.i2185, %bb8.i2178 + br label %bb25.i + +bb25.i: ; preds = %sort_ApproxStaticSortTheory.exit, %bb23.i + unreachable + +bb26.i: ; preds = %bb9.i + unreachable +} From evan.cheng at apple.com Tue Jun 16 02:15:05 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 16 Jun 2009 07:15:05 -0000 Subject: [llvm-commits] [llvm] r73479 - in /llvm/trunk/lib/CodeGen: SimpleRegisterCoalescing.cpp SimpleRegisterCoalescing.h Message-ID: <200906160715.n5G7F5vE028556@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jun 16 02:15:05 2009 New Revision: 73479 URL: http://llvm.org/viewvc/llvm-project?rev=73479&view=rev Log: Rename RemoveCopiesFromValNo to TurnCopiesFromValNoToImpDefs. Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=73479&r1=73478&r2=73479&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Tue Jun 16 02:15:05 2009 @@ -963,11 +963,11 @@ } -/// RemoveCopiesFromValNo - The specified value# is defined by an implicit -/// def and it is being removed. Turn all copies from this value# into -/// implicit_defs. -void SimpleRegisterCoalescing::RemoveCopiesFromValNo(LiveInterval &li, - VNInfo *VNI) { +/// TurnCopiesFromValNoToImpDefs - The specified value# is defined by an +/// implicit_def and it is being removed. Turn all copies from this value# +/// into implicit_defs. +void SimpleRegisterCoalescing::TurnCopiesFromValNoToImpDefs(LiveInterval &li, + VNInfo *VNI) { SmallVector ImpDefs; MachineOperand *LastUse = NULL; unsigned LastUseIdx = li_->getUseIndex(VNI->def); @@ -1775,7 +1775,7 @@ VNInfo *ImpVal = LR->valno; assert(ImpVal->def == CopyIdx); unsigned NextDef = LR->end; - RemoveCopiesFromValNo(*ResDstInt, ImpVal); + TurnCopiesFromValNoToImpDefs(*ResDstInt, ImpVal); ResDstInt->removeValNo(ImpVal); LR = ResDstInt->FindLiveRangeContaining(NextDef); if (LR != ResDstInt->end() && LR->valno->def == NextDef) { Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h?rev=73479&r1=73478&r2=73479&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Tue Jun 16 02:15:05 2009 @@ -219,10 +219,10 @@ bool CanCoalesceWithImpDef(MachineInstr *CopyMI, LiveInterval &li, LiveInterval &ImpLi) const; - /// RemoveCopiesFromValNo - The specified value# is defined by an implicit - /// def and it is being removed. Turn all copies from this value# into - /// identity copies so they will be removed. - void RemoveCopiesFromValNo(LiveInterval &li, VNInfo *VNI); + /// TurnCopiesFromValNoToImpDefs - The specified value# is defined by an + /// implicit_def and it is being removed. Turn all copies from this value# + /// into implicit_defs. + void TurnCopiesFromValNoToImpDefs(LiveInterval &li, VNInfo *VNI); /// isWinToJoinVRWithSrcPhysReg - Return true if it's worth while to join a /// a virtual destination register with physical source register. From edwintorok at gmail.com Tue Jun 16 02:19:32 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Tue, 16 Jun 2009 10:19:32 +0300 Subject: [llvm-commits] [PATCH] Avoid use after free in ScalarEvolution In-Reply-To: <2BDFCF40-1E6F-47E3-917D-E1148DE31CF7@apple.com> References: <4A16816C.7080405@gmail.com> <4AFCEFE6-6B21-4B33-998F-DACE37C5235E@apple.com> <4A369661.8050909@gmail.com> <2BDFCF40-1E6F-47E3-917D-E1148DE31CF7@apple.com> Message-ID: <4A374784.3030607@gmail.com> On 2009-06-15 23:23, Dan Gohman wrote: > On Jun 15, 2009, at 11:43 AM, T?r?k Edwin wrote: > > > >> On 2009-06-15 21:15, Dan Gohman wrote: >> >> >>> Hi Edwin, >>> >>> >>> >>> WritingAnLLVMPass.htm's description of releaseMemory says "This >>> method >>> >>> is >>> >>> called after the run* method for the class, before the next call of >>> run* >>> >>> in your pass." This suggests that it's a bug in the PassManager >>> for not >>> >>> calling releaseMemory for on-the-fly analyses. >>> >>> >>> >>> >> Would it be OK with you if I file a PR, and then try to provide a >> patch >> to do that? >> And also add an assertion before calling run() that checks that >> releaseMemory was called. >> > > Sounds good to me. > I opened PR4398. > >> >>> On the other hand, I do see several other existing passes calling >>> >>> releaseMemory or the equivalent at the top of their run functions. >>> >>> >>> >>> >> If the passmanager will properly call releaseMemory, could we patch >> them >> not to do that? >> (And for passes that have a releaseMemory equivalent that isn;'t >> called >> that, rename it). >> > > Sure. > Thanks, --Edwin From sanjiv.gupta at microchip.com Tue Jun 16 04:04:04 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Tue, 16 Jun 2009 09:04:04 -0000 Subject: [llvm-commits] [llvm] r73480 - in /llvm/trunk: include/llvm/CodeGen/RuntimeLibcalls.h lib/CodeGen/SelectionDAG/TargetLowering.cpp Message-ID: <200906160904.n5G945GK010723@zion.cs.uiuc.edu> Author: sgupta Date: Tue Jun 16 04:03:58 2009 New Revision: 73480 URL: http://llvm.org/viewvc/llvm-project?rev=73480&view=rev Log: Added required libcalls for PIC16 (mostly floating points to integer casting operations). Modified: llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Modified: llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h?rev=73480&r1=73479&r2=73480&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h (original) +++ llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h Tue Jun 16 04:03:58 2009 @@ -153,6 +153,8 @@ FPROUND_PPCF128_F32, FPROUND_F80_F64, FPROUND_PPCF128_F64, + FPTOSINT_F32_I8, + FPTOSINT_F32_I16, FPTOSINT_F32_I32, FPTOSINT_F32_I64, FPTOSINT_F32_I128, @@ -165,6 +167,8 @@ FPTOSINT_PPCF128_I32, FPTOSINT_PPCF128_I64, FPTOSINT_PPCF128_I128, + FPTOUINT_F32_I8, + FPTOUINT_F32_I16, FPTOUINT_F32_I32, FPTOUINT_F32_I64, FPTOUINT_F32_I128, @@ -177,6 +181,8 @@ FPTOUINT_PPCF128_I32, FPTOUINT_PPCF128_I64, FPTOUINT_PPCF128_I128, + SINTTOFP_I32_F8, + SINTTOFP_I32_F16, SINTTOFP_I32_F32, SINTTOFP_I32_F64, SINTTOFP_I32_F80, @@ -189,6 +195,8 @@ SINTTOFP_I128_F64, SINTTOFP_I128_F80, SINTTOFP_I128_PPCF128, + UINTTOFP_I32_F8, + UINTTOFP_I32_F16, UINTTOFP_I32_F32, UINTTOFP_I32_F64, UINTTOFP_I32_F80, Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=73480&r1=73479&r2=73480&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Tue Jun 16 04:03:58 2009 @@ -171,6 +171,8 @@ Names[RTLIB::FPROUND_PPCF128_F32] = "__trunctfsf2"; Names[RTLIB::FPROUND_F80_F64] = "__truncxfdf2"; Names[RTLIB::FPROUND_PPCF128_F64] = "__trunctfdf2"; + Names[RTLIB::FPTOSINT_F32_I8] = "__fixsfsi"; + Names[RTLIB::FPTOSINT_F32_I16] = "__fixsfsi"; Names[RTLIB::FPTOSINT_F32_I32] = "__fixsfsi"; Names[RTLIB::FPTOSINT_F32_I64] = "__fixsfdi"; Names[RTLIB::FPTOSINT_F32_I128] = "__fixsfti"; @@ -183,6 +185,8 @@ Names[RTLIB::FPTOSINT_PPCF128_I32] = "__fixtfsi"; Names[RTLIB::FPTOSINT_PPCF128_I64] = "__fixtfdi"; Names[RTLIB::FPTOSINT_PPCF128_I128] = "__fixtfti"; + Names[RTLIB::FPTOUINT_F32_I8] = "__fixunssfsi"; + Names[RTLIB::FPTOUINT_F32_I16] = "__fixunssfsi"; Names[RTLIB::FPTOUINT_F32_I32] = "__fixunssfsi"; Names[RTLIB::FPTOUINT_F32_I64] = "__fixunssfdi"; Names[RTLIB::FPTOUINT_F32_I128] = "__fixunssfti"; @@ -195,6 +199,8 @@ Names[RTLIB::FPTOUINT_PPCF128_I32] = "__fixunstfsi"; Names[RTLIB::FPTOUINT_PPCF128_I64] = "__fixunstfdi"; Names[RTLIB::FPTOUINT_PPCF128_I128] = "__fixunstfti"; + Names[RTLIB::SINTTOFP_I32_F8] = "__floatsisf"; + Names[RTLIB::SINTTOFP_I32_F16] = "__floatsisf"; Names[RTLIB::SINTTOFP_I32_F32] = "__floatsisf"; Names[RTLIB::SINTTOFP_I32_F64] = "__floatsidf"; Names[RTLIB::SINTTOFP_I32_F80] = "__floatsixf"; @@ -207,6 +213,8 @@ Names[RTLIB::SINTTOFP_I128_F64] = "__floattidf"; Names[RTLIB::SINTTOFP_I128_F80] = "__floattixf"; Names[RTLIB::SINTTOFP_I128_PPCF128] = "__floattitf"; + Names[RTLIB::UINTTOFP_I32_F8] = "__floatunsisf"; + Names[RTLIB::UINTTOFP_I32_F16] = "__floatunsisf"; Names[RTLIB::UINTTOFP_I32_F32] = "__floatunsisf"; Names[RTLIB::UINTTOFP_I32_F64] = "__floatunsidf"; Names[RTLIB::UINTTOFP_I32_F80] = "__floatunsixf"; @@ -271,6 +279,10 @@ /// UNKNOWN_LIBCALL if there is none. RTLIB::Libcall RTLIB::getFPTOSINT(MVT OpVT, MVT RetVT) { if (OpVT == MVT::f32) { + if (RetVT == MVT::i8) + return FPTOSINT_F32_I8; + if (RetVT == MVT::i16) + return FPTOSINT_F32_I16; if (RetVT == MVT::i32) return FPTOSINT_F32_I32; if (RetVT == MVT::i64) @@ -306,6 +318,10 @@ /// UNKNOWN_LIBCALL if there is none. RTLIB::Libcall RTLIB::getFPTOUINT(MVT OpVT, MVT RetVT) { if (OpVT == MVT::f32) { + if (RetVT == MVT::i8) + return FPTOUINT_F32_I8; + if (RetVT == MVT::i16) + return FPTOUINT_F32_I16; if (RetVT == MVT::i32) return FPTOUINT_F32_I32; if (RetVT == MVT::i64) From baldrick at free.fr Tue Jun 16 04:12:42 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 16 Jun 2009 11:12:42 +0200 Subject: [llvm-commits] [llvm] r73480 - in /llvm/trunk: include/llvm/CodeGen/RuntimeLibcalls.h lib/CodeGen/SelectionDAG/TargetLowering.cpp In-Reply-To: <200906160904.n5G945GK010723@zion.cs.uiuc.edu> References: <200906160904.n5G945GK010723@zion.cs.uiuc.edu> Message-ID: <4A37620A.2060901@free.fr> Hi Sanjiv, > + Names[RTLIB::FPTOSINT_F32_I8] = "__fixsfsi"; > + Names[RTLIB::FPTOSINT_F32_I16] = "__fixsfsi"; these names are the same. > + Names[RTLIB::FPTOUINT_F32_I8] = "__fixunssfsi"; > + Names[RTLIB::FPTOUINT_F32_I16] = "__fixunssfsi"; Likewise. > + Names[RTLIB::SINTTOFP_I32_F8] = "__floatsisf"; > + Names[RTLIB::SINTTOFP_I32_F16] = "__floatsisf"; Likewise. > + Names[RTLIB::UINTTOFP_I32_F8] = "__floatunsisf"; > + Names[RTLIB::UINTTOFP_I32_F16] = "__floatunsisf"; Likewise. Ciao, Duncan. From fvbommel at wxs.nl Tue Jun 16 04:21:31 2009 From: fvbommel at wxs.nl (Frits van Bommel) Date: Tue, 16 Jun 2009 11:21:31 +0200 Subject: [llvm-commits] [llvm] r73477 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp test/CodeGen/CellSPU/mul-with-overflow.ll test/CodeGen/PowerPC/mul-with-overflow.ll test/CodeGen/X86/umul-with-overflow.ll In-Reply-To: <200906160658.n5G6wT6x027997@zion.cs.uiuc.edu> References: <200906160658.n5G6wT6x027997@zion.cs.uiuc.edu> Message-ID: <4A37641B.1060506@wxs.nl> Eli Friedman wrote: > Author: efriedma > Date: Tue Jun 16 01:58:29 2009 > New Revision: 73477 > > URL: http://llvm.org/viewvc/llvm-project?rev=73477&view=rev > Log: > Add some generic expansion logic for SMULO and UMULO. Fixes UMULO > support for x86, and UMULO/SMULO for many architectures, including PPC > (PR4201), ARM, and Cell. The resulting expansion isn't perfect, but it's > not bad. Does this mean the "Warning: 'llvm.umul.with.overflow' is badly broken. It is actively being fixed, but it should not currently be used!" text from LangRef.html can now be removed? From sanjiv.gupta at microchip.com Tue Jun 16 04:45:24 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Tue, 16 Jun 2009 09:45:24 -0000 Subject: [llvm-commits] [llvm] r73481 - in /llvm/trunk/lib/Target/PIC16: PIC16AsmPrinter.cpp PIC16AsmPrinter.h PIC16DebugInfo.cpp PIC16DebugInfo.h Message-ID: <200906160945.n5G9jPON012525@zion.cs.uiuc.edu> Author: sgupta Date: Tue Jun 16 04:45:18 2009 New Revision: 73481 URL: http://llvm.org/viewvc/llvm-project?rev=73481&view=rev Log: Code Restructuring. No functionality change. Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp?rev=73481&r1=73480&r2=73481&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Tue Jun 16 04:45:18 2009 @@ -48,27 +48,10 @@ const Function *F = MF.getFunction(); CurrentFnName = Mang->getValueName(F); - // Iterate over the first basic block instructions to find if it has a - // DebugLoc. If so emit .file directive. Instructions such as movlw do not - // have valid DebugLoc, so need to iterate over instructions. - MachineFunction::const_iterator I = MF.begin(); - for (MachineBasicBlock::const_iterator MBBI = I->begin(), E = I->end(); - MBBI != E; MBBI++) { - const DebugLoc DLoc = MBBI->getDebugLoc(); - if (!DLoc.isUnknown()) { - GlobalVariable *CU = MF.getDebugLocTuple(DLoc).CompileUnit; - unsigned line = MF.getDebugLocTuple(DLoc).Line; - DbgInfo.EmitFileDirective(CU); - DbgInfo.SetFunctBeginLine(line); - break; - } - } - // Emit the function frame (args and temps). EmitFunctionFrame(MF); - // Emit function begin debug directive. - DbgInfo.EmitFunctBeginDI(F); + DbgInfo.BeginFunction(MF); // Emit the autos section of function. EmitAutos(CurrentFnName); @@ -89,9 +72,7 @@ // Emit function start label. O << CurrentFnName << ":\n"; - // For emitting line directives, we need to keep track of the current - // source line. When it changes then only emit the line directive. - unsigned CurLine = 0; + DebugLoc CurDL; O << "\n"; // Print out code for the function. for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); @@ -109,12 +90,9 @@ // Emit the line directive if source line changed. const DebugLoc DL = II->getDebugLoc(); - if (!DL.isUnknown()) { - unsigned line = MF.getDebugLocTuple(DL).Line; - if (line != CurLine) { - O << "\t.line " << line << "\n"; - CurLine = line; - } + if (!DL.isUnknown() && DL != CurDL) { + DbgInfo.ChangeDebugLoc(MF, DL); + CurDL = DL; } // Print the assembly for the instruction. @@ -123,7 +101,7 @@ } // Emit function end debug directives. - DbgInfo.EmitFunctEndDI(F, CurLine); + DbgInfo.EndFunction(MF); return false; // we didn't modify anything. } @@ -226,7 +204,7 @@ I->setSection(TAI->SectionForGlobal(I)->getName()); } - DbgInfo.Init(M); + DbgInfo.BeginModule(M); EmitFunctionDecls(M); EmitUndefinedVars(M); EmitDefinedVars(M); @@ -313,8 +291,7 @@ bool PIC16AsmPrinter::doFinalization(Module &M) { printLibcallDecls(); EmitRemainingAutos(); - DbgInfo.EmitVarDebugInfo(M); - DbgInfo.EmitEOF(); + DbgInfo.EndModule(M); O << "\n\t" << "END\n"; bool Result = AsmPrinter::doFinalization(M); return Result; Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h?rev=73481&r1=73480&r2=73481&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.h Tue Jun 16 04:45:18 2009 @@ -32,7 +32,7 @@ explicit PIC16AsmPrinter(raw_ostream &O, PIC16TargetMachine &TM, const TargetAsmInfo *T, CodeGenOpt::Level OL, bool V) - : AsmPrinter(O, TM, T, OL, V), DbgInfo(O,T) { + : AsmPrinter(O, TM, T, OL, V), DbgInfo(O, T) { PTLI = TM.getTargetLowering(); PTAI = static_cast (T); } Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=73481&r1=73480&r2=73481&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Tue Jun 16 04:45:18 2009 @@ -14,91 +14,23 @@ #include "PIC16.h" #include "PIC16DebugInfo.h" #include "llvm/GlobalVariable.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/DebugLoc.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; -void PIC16DbgInfo::PopulateDebugInfo(DIType Ty, unsigned short &TypeNo, - bool &HasAux, int Aux[], - std::string &TypeName) { - if (Ty.isBasicType(Ty.getTag())) { - std::string Name = ""; - Ty.getName(Name); - unsigned short BaseTy = GetTypeDebugNumber(Name); - TypeNo = TypeNo << PIC16Dbg::S_BASIC; - TypeNo = TypeNo | (0xffff & BaseTy); - } - else if (Ty.isDerivedType(Ty.getTag())) { - switch(Ty.getTag()) - { - case dwarf::DW_TAG_pointer_type: - TypeNo = TypeNo << PIC16Dbg::S_DERIVED; - TypeNo = TypeNo | PIC16Dbg::DT_PTR; - break; - default: - TypeNo = TypeNo << PIC16Dbg::S_DERIVED; - } - DIType BaseType = DIDerivedType(Ty.getGV()).getTypeDerivedFrom(); - PopulateDebugInfo(BaseType, TypeNo, HasAux, Aux, TypeName); - } - else if (Ty.isCompositeType(Ty.getTag())) { - switch (Ty.getTag()) { - case dwarf::DW_TAG_array_type: { - DICompositeType CTy = DICompositeType(Ty.getGV()); - DIArray Elements = CTy.getTypeArray(); - unsigned short size = 1; - unsigned short Dimension[4]={0,0,0,0}; - for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { - DIDescriptor Element = Elements.getElement(i); - if (Element.getTag() == dwarf::DW_TAG_subrange_type) { - TypeNo = TypeNo << PIC16Dbg::S_DERIVED; - TypeNo = TypeNo | PIC16Dbg::DT_ARY; - DISubrange SubRange = DISubrange(Element.getGV()); - Dimension[i] = SubRange.getHi() - SubRange.getLo() + 1; - // Each dimension is represented by 2 bytes starting at byte 9. - Aux[8+i*2+0] = Dimension[i]; - Aux[8+i*2+1] = Dimension[i] >> 8; - size = size * Dimension[i]; - } - } - HasAux = true; - // In auxillary entry for array, 7th and 8th byte represent array size. - Aux[6] = size & 0xff; - Aux[7] = size >> 8; - DIType BaseType = CTy.getTypeDerivedFrom(); - PopulateDebugInfo(BaseType, TypeNo, HasAux, Aux, TypeName); - - break; - } - case dwarf:: DW_TAG_union_type: - case dwarf::DW_TAG_structure_type: { - DICompositeType CTy = DICompositeType(Ty.getGV()); - TypeNo = TypeNo << PIC16Dbg::S_BASIC; - if (Ty.getTag() == dwarf::DW_TAG_structure_type) - TypeNo = TypeNo | PIC16Dbg::T_STRUCT; - else - TypeNo = TypeNo | PIC16Dbg::T_UNION; - CTy.getName(TypeName); - // UniqueSuffix is .number where number is obtained from - // llvm.dbg.composite. - std::string UniqueSuffix = "." + Ty.getGV()->getName().substr(18); - TypeName += UniqueSuffix; - unsigned short size = CTy.getSizeInBits()/8; - // 7th and 8th byte represent size. - HasAux = true; - Aux[6] = size & 0xff; - Aux[7] = size >> 8; - break; - } - case dwarf::DW_TAG_enumeration_type: { - TypeNo = TypeNo << PIC16Dbg::S_BASIC; - TypeNo = TypeNo | PIC16Dbg::T_ENUM; - break; - } - default: - TypeNo = TypeNo << PIC16Dbg::S_DERIVED; - } - } +/// PopulateDebugInfo - Populate the TypeNo, Aux[] and TagName from Ty. +/// +void PIC16DbgInfo::PopulateDebugInfo (DIType Ty, unsigned short &TypeNo, + bool &HasAux, int Aux[], + std::string &TagName) { + if (Ty.isBasicType(Ty.getTag())) + PopulateBasicTypeInfo (Ty, TypeNo); + else if (Ty.isDerivedType(Ty.getTag())) + PopulateDerivedTypeInfo (Ty, TypeNo, HasAux, Aux, TagName); + else if (Ty.isCompositeType(Ty.getTag())) + PopulateCompositeTypeInfo (Ty, TypeNo, HasAux, Aux, TagName); else { TypeNo = PIC16Dbg::T_NULL; HasAux = false; @@ -106,7 +38,127 @@ return; } +/// PopulateBasicTypeInfo- Populate TypeNo for basic type from Ty. +/// +void PIC16DbgInfo::PopulateBasicTypeInfo (DIType Ty, unsigned short &TypeNo) { + std::string Name = ""; + Ty.getName(Name); + unsigned short BaseTy = GetTypeDebugNumber(Name); + TypeNo = TypeNo << PIC16Dbg::S_BASIC; + TypeNo = TypeNo | (0xffff & BaseTy); +} + +/// PopulateDerivedTypeInfo - Populate TypeNo, Aux[], TagName for derived type +/// from Ty. Derived types are mostly pointers. +/// +void PIC16DbgInfo::PopulateDerivedTypeInfo (DIType Ty, unsigned short &TypeNo, + bool &HasAux, int Aux[], + std::string &TagName) { + + switch(Ty.getTag()) + { + case dwarf::DW_TAG_pointer_type: + TypeNo = TypeNo << PIC16Dbg::S_DERIVED; + TypeNo = TypeNo | PIC16Dbg::DT_PTR; + break; + default: + TypeNo = TypeNo << PIC16Dbg::S_DERIVED; + } + + // We also need to encode the the information about the base type of + // pointer in TypeNo. + DIType BaseType = DIDerivedType(Ty.getGV()).getTypeDerivedFrom(); + PopulateDebugInfo(BaseType, TypeNo, HasAux, Aux, TagName); +} + +/// PopulateArrayTypeInfo - Populate TypeNo, Aux[] for array from Ty. +void PIC16DbgInfo::PopulateArrayTypeInfo (DIType Ty, unsigned short &TypeNo, + bool &HasAux, int Aux[], + std::string &TagName) { + + DICompositeType CTy = DICompositeType(Ty.getGV()); + DIArray Elements = CTy.getTypeArray(); + unsigned short size = 1; + unsigned short Dimension[4]={0,0,0,0}; + for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { + DIDescriptor Element = Elements.getElement(i); + if (Element.getTag() == dwarf::DW_TAG_subrange_type) { + TypeNo = TypeNo << PIC16Dbg::S_DERIVED; + TypeNo = TypeNo | PIC16Dbg::DT_ARY; + DISubrange SubRange = DISubrange(Element.getGV()); + Dimension[i] = SubRange.getHi() - SubRange.getLo() + 1; + // Each dimension is represented by 2 bytes starting at byte 9. + Aux[8+i*2+0] = Dimension[i]; + Aux[8+i*2+1] = Dimension[i] >> 8; + size = size * Dimension[i]; + } + } + HasAux = true; + // In auxillary entry for array, 7th and 8th byte represent array size. + Aux[6] = size & 0xff; + Aux[7] = size >> 8; + DIType BaseType = CTy.getTypeDerivedFrom(); + PopulateDebugInfo(BaseType, TypeNo, HasAux, Aux, TagName); +} +/// PopulateStructOrUnionTypeInfo - Populate TypeNo, Aux[] , TagName for +/// structure or union. +/// +void PIC16DbgInfo::PopulateStructOrUnionTypeInfo (DIType Ty, + unsigned short &TypeNo, + bool &HasAux, int Aux[], + std::string &TagName) { + DICompositeType CTy = DICompositeType(Ty.getGV()); + TypeNo = TypeNo << PIC16Dbg::S_BASIC; + if (Ty.getTag() == dwarf::DW_TAG_structure_type) + TypeNo = TypeNo | PIC16Dbg::T_STRUCT; + else + TypeNo = TypeNo | PIC16Dbg::T_UNION; + CTy.getName(TagName); + // UniqueSuffix is .number where number is obtained from + // llvm.dbg.composite. + std::string UniqueSuffix = "." + Ty.getGV()->getName().substr(18); + TagName += UniqueSuffix; + unsigned short size = CTy.getSizeInBits()/8; + // 7th and 8th byte represent size. + HasAux = true; + Aux[6] = size & 0xff; + Aux[7] = size >> 8; +} + +/// PopulateEnumTypeInfo - Populate TypeNo for enum from Ty. +void PIC16DbgInfo::PopulateEnumTypeInfo (DIType Ty, unsigned short &TypeNo) { + TypeNo = TypeNo << PIC16Dbg::S_BASIC; + TypeNo = TypeNo | PIC16Dbg::T_ENUM; +} + +/// PopulateCompositeTypeInfo - Populate TypeNo, Aux[] and TagName for +/// composite types from Ty. +/// +void PIC16DbgInfo::PopulateCompositeTypeInfo (DIType Ty, unsigned short &TypeNo, + bool &HasAux, int Aux[], + std::string &TagName) { + switch (Ty.getTag()) { + case dwarf::DW_TAG_array_type: { + PopulateArrayTypeInfo (Ty, TypeNo, HasAux, Aux, TagName); + break; + } + case dwarf:: DW_TAG_union_type: + case dwarf::DW_TAG_structure_type: { + PopulateStructOrUnionTypeInfo (Ty, TypeNo, HasAux, Aux, TagName); + break; + } + case dwarf::DW_TAG_enumeration_type: { + PopulateEnumTypeInfo (Ty, TypeNo); + break; + } + default: + TypeNo = TypeNo << PIC16Dbg::S_DERIVED; + } +} + +/// GetTypeDebugNumber - Get debug type number for given type. +/// unsigned PIC16DbgInfo::GetTypeDebugNumber(std::string &type) { if (type == "char") return PIC16Dbg::T_CHAR; @@ -127,8 +179,10 @@ else return 0; } - -short PIC16DbgInfo::getClass(DIGlobalVariable DIGV) { + +/// GetStorageClass - Get storage class for give debug variable. +/// +short PIC16DbgInfo::getStorageClass(DIGlobalVariable DIGV) { short ClassNo; if (PAN::isLocalName(DIGV.getGlobal()->getName())) { // Generating C_AUTO here fails due to error in linker. Change it once @@ -142,12 +196,126 @@ return ClassNo; } -void PIC16DbgInfo::Init(Module &M) { - // Do all debug related initializations here. - EmitFileDirective(M); +/// BeginModule - Emit necessary debug info to start a Module and do other +/// required initializations. +void PIC16DbgInfo::BeginModule(Module &M) { + // Emit file directive for module. + GlobalVariable *CU = M.getNamedGlobal("llvm.dbg.compile_unit"); + if (CU) { + EmitDebugDirectives = true; + SwitchToCU(CU); + } + + // Emit debug info for decls of composite types. EmitCompositeTypeDecls(M); } +/// Helper to find first valid debug loc for a function. +/// +static const DebugLoc GetDebugLocForFunction(const MachineFunction &MF) { + DebugLoc DL; + for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); + I != E; ++I) { + for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); + II != E; ++II) { + DL = II->getDebugLoc(); + if (!DL.isUnknown()) + return DL; + } + } + return DL; +} + +/// BeginFunction - Emit necessary debug info to start a function. +/// +void PIC16DbgInfo::BeginFunction(const MachineFunction &MF) { + if (! EmitDebugDirectives) return; + + // Retreive the first valid debug Loc and process it. + const DebugLoc &DL = GetDebugLocForFunction(MF); + ChangeDebugLoc(MF, DL, true); + + EmitFunctBeginDI(MF.getFunction()); + + // Set current line to 0 so that.line directive is genearted after .bf. + CurLine = 0; +} + +/// ChangeDebugLoc - Take necessary steps when DebugLoc changes. +/// CurFile and CurLine may change as a result of this. +/// +void PIC16DbgInfo::ChangeDebugLoc(const MachineFunction &MF, + const DebugLoc &DL, bool IsInBeginFunction) { + if (! EmitDebugDirectives) return; + assert (! DL.isUnknown() && "can't change to invalid debug loc"); + + GlobalVariable *CU = MF.getDebugLocTuple(DL).CompileUnit; + unsigned line = MF.getDebugLocTuple(DL).Line; + + SwitchToCU(CU); + SwitchToLine(line, IsInBeginFunction); +} + +/// SwitchToLine - Emit line directive for a new line. +/// +void PIC16DbgInfo::SwitchToLine(unsigned Line, bool IsInBeginFunction) { + if (CurLine == Line) return; + if (!IsInBeginFunction) O << "\n\t.line " << Line << "\n"; + CurLine = Line; +} + +/// EndFunction - Emit .ef for end of function. +/// +void PIC16DbgInfo::EndFunction(const MachineFunction &MF) { + if (! EmitDebugDirectives) return; + EmitFunctEndDI(MF.getFunction(), CurLine); +} + +/// EndModule - Emit .eof for end of module. +/// +void PIC16DbgInfo::EndModule(Module &M) { + if (! EmitDebugDirectives) return; + EmitVarDebugInfo(M); + if (CurFile != "") O << "\n\t.eof"; +} + +/// EmitCompositeTypeElements - Emit debug information for members of a +/// composite type. +/// +void PIC16DbgInfo::EmitCompositeTypeElements (DICompositeType CTy, + std::string UniqueSuffix) { + unsigned long Value = 0; + DIArray Elements = CTy.getTypeArray(); + for (unsigned i = 0, N = Elements.getNumElements(); i < N; i++) { + DIDescriptor Element = Elements.getElement(i); + unsigned short TypeNo = 0; + bool HasAux = false; + int ElementAux[PIC16Dbg::AuxSize] = { 0 }; + std::string TagName = ""; + std::string ElementName; + GlobalVariable *GV = Element.getGV(); + DIDerivedType DITy(GV); + DITy.getName(ElementName); + unsigned short ElementSize = DITy.getSizeInBits()/8; + // Get mangleddd name for this structure/union element. + std::string MangMemName = ElementName + UniqueSuffix; + PopulateDebugInfo(DITy, TypeNo, HasAux, ElementAux, TagName); + short Class; + if( CTy.getTag() == dwarf::DW_TAG_union_type) + Class = PIC16Dbg::C_MOU; + else if (CTy.getTag() == dwarf::DW_TAG_structure_type) + Class = PIC16Dbg::C_MOS; + EmitSymbol(MangMemName, Class, TypeNo, Value); + if (CTy.getTag() == dwarf::DW_TAG_structure_type) + Value += ElementSize; + if (HasAux) + EmitAuxEntry(MangMemName, ElementAux, PIC16Dbg::AuxSize, TagName); + } +} + +/// EmitCompositeTypeDecls - Emit composite type declarations like structure +/// and union declarations. +/// void PIC16DbgInfo::EmitCompositeTypeDecls(Module &M) { for(iplist::iterator I = M.getGlobalList().begin(), E = M.getGlobalList().end(); I != E; I++) { @@ -178,33 +346,10 @@ // Emit auxiliary debug information for structure/union tag. EmitAuxEntry(MangledCTyName, Aux, PIC16Dbg::AuxSize); - unsigned long Value = 0; - DIArray Elements = CTy.getTypeArray(); - for (unsigned i = 0, N = Elements.getNumElements(); i < N; i++) { - DIDescriptor Element = Elements.getElement(i); - unsigned short TypeNo = 0; - bool HasAux = false; - int ElementAux[PIC16Dbg::AuxSize] = { 0 }; - std::string TypeName = ""; - std::string ElementName; - GlobalVariable *GV = Element.getGV(); - DIDerivedType DITy(GV); - DITy.getName(ElementName); - unsigned short ElementSize = DITy.getSizeInBits()/8; - // Get mangleddd name for this structure/union element. - std::string MangMemName = ElementName + UniqueSuffix; - PopulateDebugInfo(DITy, TypeNo, HasAux, ElementAux, TypeName); - short Class; - if( CTy.getTag() == dwarf::DW_TAG_union_type) - Class = PIC16Dbg::C_MOU; - else if (CTy.getTag() == dwarf::DW_TAG_structure_type) - Class = PIC16Dbg::C_MOS; - EmitSymbol(MangMemName, Class, TypeNo, Value); - if (CTy.getTag() == dwarf::DW_TAG_structure_type) - Value += ElementSize; - if (HasAux) - EmitAuxEntry(MangMemName, ElementAux, PIC16Dbg::AuxSize, TypeName); - } + + // Emit members. + EmitCompositeTypeElements (CTy, UniqueSuffix); + // Emit mangled Symbol for end of structure/union. std::string EOSSymbol = ".eos" + UniqueSuffix; EmitSymbol(EOSSymbol, PIC16Dbg::C_EOS); @@ -214,6 +359,8 @@ } } +/// EmitFunctBeginDI - Emit .bf for function. +/// void PIC16DbgInfo::EmitFunctBeginDI(const Function *F) { std::string FunctName = F->getName(); if (EmitDebugDirectives) { @@ -221,16 +368,20 @@ std::string BlockBeginSym = ".bb." + FunctName; int BFAux[PIC16Dbg::AuxSize] = {0}; - BFAux[4] = FunctBeginLine; - BFAux[5] = FunctBeginLine >> 8; + BFAux[4] = CurLine; + BFAux[5] = CurLine >> 8; + // Emit debug directives for beginning of function. EmitSymbol(FunctBeginSym, PIC16Dbg::C_FCN); EmitAuxEntry(FunctBeginSym, BFAux, PIC16Dbg::AuxSize); + EmitSymbol(BlockBeginSym, PIC16Dbg::C_BLOCK); EmitAuxEntry(BlockBeginSym, BFAux, PIC16Dbg::AuxSize); } } +/// EmitFunctEndDI - Emit .ef for function end. +/// void PIC16DbgInfo::EmitFunctEndDI(const Function *F, unsigned Line) { std::string FunctName = F->getName(); if (EmitDebugDirectives) { @@ -241,8 +392,8 @@ EmitSymbol(BlockEndSym, PIC16Dbg::C_BLOCK); int EFAux[PIC16Dbg::AuxSize] = {0}; // 5th and 6th byte stand for line number. - EFAux[4] = Line; - EFAux[5] = Line >> 8; + EFAux[4] = CurLine; + EFAux[5] = CurLine >> 8; EmitAuxEntry(BlockEndSym, EFAux, PIC16Dbg::AuxSize); EmitSymbol(FunctEndSym, PIC16Dbg::C_FCN); EmitAuxEntry(FunctEndSym, EFAux, PIC16Dbg::AuxSize); @@ -251,15 +402,18 @@ /// EmitAuxEntry - Emit Auxiliary debug information. /// -void PIC16DbgInfo::EmitAuxEntry(const std::string VarName, int Aux[], int num, - std::string tag) { +void PIC16DbgInfo::EmitAuxEntry(const std::string VarName, int Aux[], int Num, + std::string TagName) { O << "\n\t.dim " << VarName << ", 1" ; - if (tag != "") - O << ", " << tag; - for (int i = 0; igetGlobalPrefix()+DIGV.getGlobal()->getName(); - PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TypeName); + PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TagName); // Emit debug info only if type information is availaible. if (TypeNo != PIC16Dbg::T_NULL) { O << "\n\t.type " << VarName << ", " << TypeNo; - short ClassNo = getClass(DIGV); + short ClassNo = getStorageClass(DIGV); O << "\n\t.class " << VarName << ", " << ClassNo; if (HasAux) - EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TypeName); + EmitAuxEntry(VarName, Aux, PIC16Dbg::AuxSize, TagName); } } } O << "\n"; } -void PIC16DbgInfo::EmitFileDirective(Module &M) { - GlobalVariable *CU = M.getNamedGlobal("llvm.dbg.compile_unit"); - if (CU) { - EmitDebugDirectives = true; - EmitFileDirective(CU, false); - } -} - -void PIC16DbgInfo::EmitFileDirective(GlobalVariable *CU, bool EmitEof) { - std::string Dir, FN; - DICompileUnit DIUnit(CU); - std::string File = DIUnit.getDirectory(Dir) + "/" + DIUnit.getFilename(FN); - if ( File != CurFile ) { - if (EmitEof) - EmitEOF(); - O << "\n\t.file\t\"" << File << "\"\n" ; - CurFile = File; - } +/// SwitchToCU - Switch to a new compilation unit. +/// +void PIC16DbgInfo::SwitchToCU(GlobalVariable *CU) { + // Get the file path from CU. + DICompileUnit cu(CU); + std::string DirName, FileName; + std::string FilePath = cu.getDirectory(DirName) + "/" + + cu.getFilename(FileName); + + // Nothing to do if source file is still same. + if ( FilePath == CurFile ) return; + + // Else, close the current one and start a new. + if (CurFile != "") O << "\n\t.eof"; + O << "\n\t.file\t\"" << FilePath << "\"\n" ; + CurFile = FilePath; + CurLine = 0; } +/// EmitEOF - Emit .eof for end of file. +/// void PIC16DbgInfo::EmitEOF() { if (CurFile != "") O << "\n\t.EOF"; } -void PIC16DbgInfo::SetFunctBeginLine(unsigned line) { - FunctBeginLine = line; -} Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h?rev=73481&r1=73480&r2=73481&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h Tue Jun 16 04:45:18 2009 @@ -20,6 +20,8 @@ #include namespace llvm { + class MachineFunction; + class DebugLoc; namespace PIC16Dbg { enum VarType { T_NULL, @@ -94,33 +96,64 @@ raw_ostream &O; const TargetAsmInfo *TAI; std::string CurFile; + unsigned CurLine; + // EmitDebugDirectives is set if debug information is available. Default // value for it is false. bool EmitDebugDirectives; - unsigned FunctBeginLine; + public: PIC16DbgInfo(raw_ostream &o, const TargetAsmInfo *T) : O(o), TAI(T) { - CurFile = ""; + CurFile = ""; + CurLine = 0; EmitDebugDirectives = false; } - void PopulateDebugInfo(DIType Ty, unsigned short &TypeNo, bool &HasAux, + + void BeginModule (Module &M); + void BeginFunction (const MachineFunction &MF); + void ChangeDebugLoc (const MachineFunction &MF, const DebugLoc &DL, + bool IsInBeginFunction = false); + void EndFunction (const MachineFunction &MF); + void EndModule (Module &M); + + + private: + void SwitchToCU (GlobalVariable *CU); + void SwitchToLine (unsigned Line, bool IsInBeginFunction = false); + + void PopulateDebugInfo (DIType Ty, unsigned short &TypeNo, bool &HasAux, int Aux[], std::string &TypeName); - unsigned GetTypeDebugNumber(std::string &type); - short getClass(DIGlobalVariable DIGV); + void PopulateBasicTypeInfo (DIType Ty, unsigned short &TypeNo); + void PopulateDerivedTypeInfo (DIType Ty, unsigned short &TypeNo, + bool &HasAux, int Aux[], + std::string &TypeName); + + void PopulateCompositeTypeInfo (DIType Ty, unsigned short &TypeNo, + bool &HasAux, int Aux[], + std::string &TypeName); + void PopulateArrayTypeInfo (DIType Ty, unsigned short &TypeNo, + bool &HasAux, int Aux[], + std::string &TypeName); + + void PopulateStructOrUnionTypeInfo (DIType Ty, unsigned short &TypeNo, + bool &HasAux, int Aux[], + std::string &TypeName); + void PopulateEnumTypeInfo (DIType Ty, unsigned short &TypeNo); + + unsigned GetTypeDebugNumber(std::string &Type); + short getStorageClass(DIGlobalVariable DIGV); void EmitFunctBeginDI(const Function *F); - void Init(Module &M); void EmitCompositeTypeDecls(Module &M); + void EmitCompositeTypeElements (DICompositeType CTy, + std::string UniqueSuffix); void EmitFunctEndDI(const Function *F, unsigned Line); void EmitAuxEntry(const std::string VarName, int Aux[], - int num = PIC16Dbg::AuxSize, std::string tag = ""); + int num = PIC16Dbg::AuxSize, std::string TagName = ""); inline void EmitSymbol(std::string Name, short Class, unsigned short Type = PIC16Dbg::T_NULL, unsigned long Value = 0); void EmitVarDebugInfo(Module &M); - void EmitFileDirective(Module &M); - void EmitFileDirective(GlobalVariable *CU, bool EmitEof = true); void EmitEOF(); - void SetFunctBeginLine(unsigned line); }; } // end namespace llvm; #endif From sanjiv.gupta at microchip.com Tue Jun 16 04:49:19 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Tue, 16 Jun 2009 15:19:19 +0530 Subject: [llvm-commits] [llvm] r73448 - in /llvm/trunk/tools/llvmc/doc: LLVMC-Reference.rst LLVMC-Tutorial.rst In-Reply-To: <200906160013.n5G0DqJv014780@zion.cs.uiuc.edu> References: <200906160013.n5G0DqJv014780@zion.cs.uiuc.edu> Message-ID: <4A376A9F.4060203@microchip.com> Mikhail Glushenkov wrote: > Author: foldr > Date: Mon Jun 15 19:13:52 2009 > New Revision: 73448 > > URL: http://llvm.org/viewvc/llvm-project?rev=73448&view=rev > Log: > Documentation update. > > Thanks Mikhail. This make things a lot clearer. - Sanjiv From sanjiv.gupta at microchip.com Tue Jun 16 05:23:00 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Tue, 16 Jun 2009 10:23:00 -0000 Subject: [llvm-commits] [llvm] r73483 - in /llvm/trunk: include/llvm/CodeGen/RuntimeLibcalls.h lib/CodeGen/SelectionDAG/TargetLowering.cpp Message-ID: <200906161023.n5GAN1vF017327@zion.cs.uiuc.edu> Author: sgupta Date: Tue Jun 16 05:22:58 2009 New Revision: 73483 URL: http://llvm.org/viewvc/llvm-project?rev=73483&view=rev Log: Fixed names of libcalls checked in r73480. Modified: llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Modified: llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h?rev=73483&r1=73482&r2=73483&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h (original) +++ llvm/trunk/include/llvm/CodeGen/RuntimeLibcalls.h Tue Jun 16 05:22:58 2009 @@ -181,8 +181,6 @@ FPTOUINT_PPCF128_I32, FPTOUINT_PPCF128_I64, FPTOUINT_PPCF128_I128, - SINTTOFP_I32_F8, - SINTTOFP_I32_F16, SINTTOFP_I32_F32, SINTTOFP_I32_F64, SINTTOFP_I32_F80, @@ -195,8 +193,6 @@ SINTTOFP_I128_F64, SINTTOFP_I128_F80, SINTTOFP_I128_PPCF128, - UINTTOFP_I32_F8, - UINTTOFP_I32_F16, UINTTOFP_I32_F32, UINTTOFP_I32_F64, UINTTOFP_I32_F80, Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=73483&r1=73482&r2=73483&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Tue Jun 16 05:22:58 2009 @@ -171,8 +171,8 @@ Names[RTLIB::FPROUND_PPCF128_F32] = "__trunctfsf2"; Names[RTLIB::FPROUND_F80_F64] = "__truncxfdf2"; Names[RTLIB::FPROUND_PPCF128_F64] = "__trunctfdf2"; - Names[RTLIB::FPTOSINT_F32_I8] = "__fixsfsi"; - Names[RTLIB::FPTOSINT_F32_I16] = "__fixsfsi"; + Names[RTLIB::FPTOSINT_F32_I8] = "__fixsfi8"; + Names[RTLIB::FPTOSINT_F32_I16] = "__fixsfi16"; Names[RTLIB::FPTOSINT_F32_I32] = "__fixsfsi"; Names[RTLIB::FPTOSINT_F32_I64] = "__fixsfdi"; Names[RTLIB::FPTOSINT_F32_I128] = "__fixsfti"; @@ -185,8 +185,8 @@ Names[RTLIB::FPTOSINT_PPCF128_I32] = "__fixtfsi"; Names[RTLIB::FPTOSINT_PPCF128_I64] = "__fixtfdi"; Names[RTLIB::FPTOSINT_PPCF128_I128] = "__fixtfti"; - Names[RTLIB::FPTOUINT_F32_I8] = "__fixunssfsi"; - Names[RTLIB::FPTOUINT_F32_I16] = "__fixunssfsi"; + Names[RTLIB::FPTOUINT_F32_I8] = "__fixunssfi8"; + Names[RTLIB::FPTOUINT_F32_I16] = "__fixunssfi16"; Names[RTLIB::FPTOUINT_F32_I32] = "__fixunssfsi"; Names[RTLIB::FPTOUINT_F32_I64] = "__fixunssfdi"; Names[RTLIB::FPTOUINT_F32_I128] = "__fixunssfti"; @@ -199,8 +199,6 @@ Names[RTLIB::FPTOUINT_PPCF128_I32] = "__fixunstfsi"; Names[RTLIB::FPTOUINT_PPCF128_I64] = "__fixunstfdi"; Names[RTLIB::FPTOUINT_PPCF128_I128] = "__fixunstfti"; - Names[RTLIB::SINTTOFP_I32_F8] = "__floatsisf"; - Names[RTLIB::SINTTOFP_I32_F16] = "__floatsisf"; Names[RTLIB::SINTTOFP_I32_F32] = "__floatsisf"; Names[RTLIB::SINTTOFP_I32_F64] = "__floatsidf"; Names[RTLIB::SINTTOFP_I32_F80] = "__floatsixf"; @@ -213,8 +211,6 @@ Names[RTLIB::SINTTOFP_I128_F64] = "__floattidf"; Names[RTLIB::SINTTOFP_I128_F80] = "__floattixf"; Names[RTLIB::SINTTOFP_I128_PPCF128] = "__floattitf"; - Names[RTLIB::UINTTOFP_I32_F8] = "__floatunsisf"; - Names[RTLIB::UINTTOFP_I32_F16] = "__floatunsisf"; Names[RTLIB::UINTTOFP_I32_F32] = "__floatunsisf"; Names[RTLIB::UINTTOFP_I32_F64] = "__floatunsidf"; Names[RTLIB::UINTTOFP_I32_F80] = "__floatunsixf"; From eli.friedman at gmail.com Tue Jun 16 05:24:13 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 16 Jun 2009 10:24:13 -0000 Subject: [llvm-commits] [llvm] r73484 - /llvm/trunk/docs/LangRef.html Message-ID: <200906161024.n5GAODCt017369@zion.cs.uiuc.edu> Author: efriedma Date: Tue Jun 16 05:24:13 2009 New Revision: 73484 URL: http://llvm.org/viewvc/llvm-project?rev=73484&view=rev Log: Remove the "llvm.umul.with.overflow is broken" warning; it should be essentially working now, at least for common cases, and it shouldn't silently generate bad code. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=73484&r1=73483&r2=73484&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Tue Jun 16 05:24:13 2009 @@ -6429,9 +6429,6 @@
    Overview:
    -

    Warning: 'llvm.umul.with.overflow' is badly broken. It is -actively being fixed, but it should not currently be used!

    -

    The 'llvm.umul.with.overflow' family of intrinsic functions perform a unsigned multiplication of the two arguments, and indicate whether an overflow occurred during the unsigned multiplication.

    From anton at korobeynikov.info Tue Jun 16 06:08:23 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 16 Jun 2009 15:08:23 +0400 Subject: [llvm-commits] [llvm] r73483 - in /llvm/trunk: include/llvm/CodeGen/RuntimeLibcalls.h lib/CodeGen/SelectionDAG/TargetLowering.cpp In-Reply-To: <200906161023.n5GAN1vF017327@zion.cs.uiuc.edu> References: <200906161023.n5GAN1vF017327@zion.cs.uiuc.edu> Message-ID: Hello, Sanjiv > - Names[RTLIB::FPTOSINT_F32_I8] = "__fixsfsi"; > - Names[RTLIB::FPTOSINT_F32_I16] = "__fixsfsi"; > + Names[RTLIB::FPTOSINT_F32_I8] = "__fixsfi8"; > + Names[RTLIB::FPTOSINT_F32_I16] = "__fixsfi16"; Are you sure these are "proper" names? At least i16 variant should have "hi" suffix to follow common gcc scheme. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From espindola at google.com Tue Jun 16 06:35:56 2009 From: espindola at google.com (Rafael Espindola) Date: Tue, 16 Jun 2009 12:35:56 +0100 Subject: [llvm-commits] CVS: llvm-www/OpenProjects.html In-Reply-To: <200906160632.n5G6Wqu2027226@zion.cs.uiuc.edu> References: <200906160632.n5G6Wqu2027226@zion.cs.uiuc.edu> Message-ID: <38a0d8450906160435i40749ec2w9cc258e9448479d1@mail.gmail.com> > + ?
  • Value > + ? ? ?assertions (also PR810).
  • > ? The example int test(char *f) { if (*f) __builtin_unreachable (); return f ? 1 : 0; } should probably be int test(char *f) { if (*f) __builtin_unreachable (); return *f ? 0 : 1; } for it to be reduced to "return 1". Cheers, -- Rafael Avila de Espindola Google | Gordon House | Barrow Street | Dublin 4 | Ireland Registered in Dublin, Ireland | Registration Number: 368047 From sanjiv.gupta at microchip.com Tue Jun 16 11:17:36 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Tue, 16 Jun 2009 16:17:36 -0000 Subject: [llvm-commits] [llvm] r73491 - /llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Message-ID: <200906161617.n5GGHabn028764@zion.cs.uiuc.edu> Author: sgupta Date: Tue Jun 16 11:17:35 2009 New Revision: 73491 URL: http://llvm.org/viewvc/llvm-project?rev=73491&view=rev Log: Added missing libcalls for floating point to int conversions. Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=73491&r1=73490&r2=73491&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Tue Jun 16 11:17:35 2009 @@ -31,42 +31,72 @@ std::string Basename; switch(opcode) { default: assert (0 && "do not know intrinsic name"); + // Arithmetic Right shift for integer types. case PIC16ISD::SRA_I8: Basename = "sra.i8"; break; case RTLIB::SRA_I16: Basename = "sra.i16"; break; case RTLIB::SRA_I32: Basename = "sra.i32"; break; + // Left shift for integer types. case PIC16ISD::SLL_I8: Basename = "sll.i8"; break; case RTLIB::SHL_I16: Basename = "sll.i16"; break; case RTLIB::SHL_I32: Basename = "sll.i32"; break; + // Logical Right Shift for integer types. case PIC16ISD::SRL_I8: Basename = "srl.i8"; break; case RTLIB::SRL_I16: Basename = "srl.i16"; break; case RTLIB::SRL_I32: Basename = "srl.i32"; break; + // Multiply for integer types. case PIC16ISD::MUL_I8: Basename = "mul.i8"; break; case RTLIB::MUL_I16: Basename = "mul.i16"; break; case RTLIB::MUL_I32: Basename = "mul.i32"; break; + // Signed division for integers. case RTLIB::SDIV_I16: Basename = "sdiv.i16"; break; case RTLIB::SDIV_I32: Basename = "sdiv.i32"; break; + + // Unsigned division for integers. case RTLIB::UDIV_I16: Basename = "udiv.i16"; break; case RTLIB::UDIV_I32: Basename = "udiv.i32"; break; + // Signed Modulas for integers. case RTLIB::SREM_I16: Basename = "srem.i16"; break; case RTLIB::SREM_I32: Basename = "srem.i32"; break; + + // Unsigned Modulas for integers. case RTLIB::UREM_I16: Basename = "urem.i16"; break; case RTLIB::UREM_I32: Basename = "urem.i32"; break; - case RTLIB::FPTOSINT_F32_I32: - Basename = "f32_to_si32"; break; - case RTLIB::SINTTOFP_I32_F32: - Basename = "si32_to_f32"; break; + ////////////////////// + // LIBCALLS FOR FLOATS + ////////////////////// + + // Float to signed integrals + case RTLIB::FPTOSINT_F32_I8: Basename = "f32_to_si32"; break; + case RTLIB::FPTOSINT_F32_I16: Basename = "f32_to_si32"; break; + case RTLIB::FPTOSINT_F32_I32: Basename = "f32_to_si32"; break; + + // Signed integrals to float. char and int are first sign extended to i32 + // before being converted to float, so an I8_F32 or I16_F32 isn't required. + case RTLIB::SINTTOFP_I32_F32: Basename = "si32_to_f32"; break; + + // Float to Unsigned conversions. + // Signed conversion can be used for unsigned conversion as well. + // In signed and unsigned versions only the interpretation of the + // MSB is different. Bit representation remains the same. + case RTLIB::FPTOUINT_F32_I8: Basename = "f32_to_si32"; break; + case RTLIB::FPTOUINT_F32_I16: Basename = "f32_to_si32"; break; + case RTLIB::FPTOUINT_F32_I32: Basename = "f32_to_si32"; break; + + // Unsigned to Float conversions. char and int are first zero extended + // before being converted to float. + case RTLIB::UINTTOFP_I32_F32: Basename = "ui32_to_f32"; break; + // Floating point add, sub, mul, div. case RTLIB::ADD_F32: Basename = "add.f32"; break; case RTLIB::SUB_F32: Basename = "sub.f32"; break; case RTLIB::MUL_F32: Basename = "mul.f32"; break; case RTLIB::DIV_F32: Basename = "div.f32"; break; - } std::string prefix = PAN::getTagName(PAN::PREFIX_SYMBOL); @@ -83,7 +113,7 @@ // PIC16TargetLowering Constructor. PIC16TargetLowering::PIC16TargetLowering(PIC16TargetMachine &TM) : TargetLowering(TM), TmpSize(0) { - + Subtarget = &TM.getSubtarget(); addRegisterClass(MVT::i8, PIC16::GPRRegisterClass); @@ -114,6 +144,7 @@ // Signed division lib call names setLibcallName(RTLIB::SDIV_I16, getIntrinsicName(RTLIB::SDIV_I16)); setLibcallName(RTLIB::SDIV_I32, getIntrinsicName(RTLIB::SDIV_I32)); + // Unsigned division lib call names setLibcallName(RTLIB::UDIV_I16, getIntrinsicName(RTLIB::UDIV_I16)); setLibcallName(RTLIB::UDIV_I32, getIntrinsicName(RTLIB::UDIV_I32)); @@ -121,15 +152,36 @@ // Signed remainder lib call names setLibcallName(RTLIB::SREM_I16, getIntrinsicName(RTLIB::SREM_I16)); setLibcallName(RTLIB::SREM_I32, getIntrinsicName(RTLIB::SREM_I32)); + // Unsigned remainder lib call names setLibcallName(RTLIB::UREM_I16, getIntrinsicName(RTLIB::UREM_I16)); setLibcallName(RTLIB::UREM_I32, getIntrinsicName(RTLIB::UREM_I32)); - // Floating point operations + // Floating point to signed int conversions. + setLibcallName(RTLIB::FPTOSINT_F32_I8, + getIntrinsicName(RTLIB::FPTOSINT_F32_I8)); + setLibcallName(RTLIB::FPTOSINT_F32_I16, + getIntrinsicName(RTLIB::FPTOSINT_F32_I16)); setLibcallName(RTLIB::FPTOSINT_F32_I32, getIntrinsicName(RTLIB::FPTOSINT_F32_I32)); + + // Signed int to floats. setLibcallName(RTLIB::SINTTOFP_I32_F32, getIntrinsicName(RTLIB::SINTTOFP_I32_F32)); + + // Floating points to unsigned ints. + setLibcallName(RTLIB::FPTOUINT_F32_I8, + getIntrinsicName(RTLIB::FPTOUINT_F32_I8)); + setLibcallName(RTLIB::FPTOUINT_F32_I16, + getIntrinsicName(RTLIB::FPTOUINT_F32_I16)); + setLibcallName(RTLIB::FPTOUINT_F32_I32, + getIntrinsicName(RTLIB::FPTOUINT_F32_I32)); + + // Unsigned int to floats. + setLibcallName(RTLIB::UINTTOFP_I32_F32, + getIntrinsicName(RTLIB::UINTTOFP_I32_F32)); + + // Floating point add, sub, mul ,div. setLibcallName(RTLIB::ADD_F32, getIntrinsicName(RTLIB::ADD_F32)); setLibcallName(RTLIB::SUB_F32, getIntrinsicName(RTLIB::SUB_F32)); setLibcallName(RTLIB::MUL_F32, getIntrinsicName(RTLIB::MUL_F32)); From gohman at apple.com Tue Jun 16 12:17:55 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 16 Jun 2009 10:17:55 -0700 Subject: [llvm-commits] [llvm] r73421 - /llvm/trunk/docs/LangRef.html In-Reply-To: <4A37375D.3070406@free.fr> References: <200906152118.n5FLI25H008675@zion.cs.uiuc.edu> <4A37375D.3070406@free.fr> Message-ID: <5CD81A45-EB6A-43F0-A01F-A431FFFEC899@apple.com> On Jun 15, 2009, at 11:10 PM, Duncan Sands wrote: > Hi Dan, > > >>
    noredzone
    >> >>
    This attribute indicates that the code generator should not use a >> >> -red zone, even if it would otherwise be supported by the target- >> specific ABI. >> >> +red zone, even if the target-specific ABI normally permits it. >> >>
    >> > > thanks for changing it. Just to be totally annoying: how about > dropping > "normally". The ABI still permits a redzone whether you have > noredzone > or not. The main reason for using noredzone is to support code generation for certain OS kernels which do not permit the use of red zones even on targets where they are normally permitted, such as x86-64. This is why I included the word "normally". Dan From sabre at nondot.org Tue Jun 16 12:23:12 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 17:23:12 -0000 Subject: [llvm-commits] [llvm] r73506 - in /llvm/trunk: include/llvm/Transforms/Utils/Local.h lib/Transforms/Scalar/InstructionCombining.cpp lib/Transforms/Utils/Local.cpp Message-ID: <200906161723.n5GHNDtQ031574@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 12:23:12 2009 New Revision: 73506 URL: http://llvm.org/viewvc/llvm-project?rev=73506&view=rev Log: Generalize instcombine's isSafeToLoadUnconditionally() function to ignore readonly calls, and factor it out of instcombine so that it can be used by other passes. Patch by Frits van Bommel! Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/Transforms/Utils/Local.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=73506&r1=73505&r2=73506&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Tue Jun 16 12:23:12 2009 @@ -31,6 +31,16 @@ template class SmallVectorImpl; //===----------------------------------------------------------------------===// +// Local analysis. +// + +/// isSafeToLoadUnconditionally - Return true if we know that executing a load +/// from this value cannot trap. If it is not obviously safe to load from the +/// specified pointer, we do a quick local scan of the basic block containing +/// ScanFrom, to determine if the address is already accessed. +bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom); + +//===----------------------------------------------------------------------===// // Local constant propagation. // Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=73506&r1=73505&r2=73506&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jun 16 12:23:12 2009 @@ -11419,45 +11419,6 @@ return 0; } -/// isSafeToLoadUnconditionally - Return true if we know that executing a load -/// from this value cannot trap. If it is not obviously safe to load from the -/// specified pointer, we do a quick local scan of the basic block containing -/// ScanFrom, to determine if the address is already accessed. -static bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom) { - // If it is an alloca it is always safe to load from. - if (isa(V)) return true; - - // If it is a global variable it is mostly safe to load from. - if (const GlobalValue *GV = dyn_cast(V)) - // Don't try to evaluate aliases. External weak GV can be null. - return !isa(GV) && !GV->hasExternalWeakLinkage(); - - // Otherwise, be a little bit agressive by scanning the local block where we - // want to check to see if the pointer is already being loaded or stored - // from/to. If so, the previous load or store would have already trapped, - // so there is no harm doing an extra load (also, CSE will later eliminate - // the load entirely). - BasicBlock::iterator BBI = ScanFrom, E = ScanFrom->getParent()->begin(); - - while (BBI != E) { - --BBI; - - // If we see a free or a call (which might do a free) the pointer could be - // marked invalid. - if (isa(BBI) || - (isa(BBI) && !isa(BBI))) - return false; - - if (LoadInst *LI = dyn_cast(BBI)) { - if (LI->getOperand(0) == V) return true; - } else if (StoreInst *SI = dyn_cast(BBI)) { - if (SI->getOperand(1) == V) return true; - } - - } - return false; -} - Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { Value *Op = LI.getOperand(0); Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=73506&r1=73505&r2=73506&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Tue Jun 16 12:23:12 2009 @@ -14,6 +14,7 @@ #include "llvm/Transforms/Utils/Local.h" #include "llvm/Constants.h" +#include "llvm/GlobalAlias.h" #include "llvm/GlobalVariable.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" @@ -28,6 +29,50 @@ using namespace llvm; //===----------------------------------------------------------------------===// +// Local analysis. +// + +/// isSafeToLoadUnconditionally - Return true if we know that executing a load +/// from this value cannot trap. If it is not obviously safe to load from the +/// specified pointer, we do a quick local scan of the basic block containing +/// ScanFrom, to determine if the address is already accessed. +bool llvm::isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom) { + // If it is an alloca it is always safe to load from. + if (isa(V)) return true; + + // If it is a global variable it is mostly safe to load from. + if (const GlobalValue *GV = dyn_cast(V)) + // Don't try to evaluate aliases. External weak GV can be null. + return !isa(GV) && !GV->hasExternalWeakLinkage(); + + // Otherwise, be a little bit agressive by scanning the local block where we + // want to check to see if the pointer is already being loaded or stored + // from/to. If so, the previous load or store would have already trapped, + // so there is no harm doing an extra load (also, CSE will later eliminate + // the load entirely). + BasicBlock::iterator BBI = ScanFrom, E = ScanFrom->getParent()->begin(); + + while (BBI != E) { + --BBI; + + // If we see a free or a call which may write to memory (i.e. which might do + // a free) the pointer could be marked invalid. + if (isa(BBI) || + (isa(BBI) && BBI->mayWriteToMemory() && + !isa(BBI))) + return false; + + if (LoadInst *LI = dyn_cast(BBI)) { + if (LI->getOperand(0) == V) return true; + } else if (StoreInst *SI = dyn_cast(BBI)) { + if (SI->getOperand(1) == V) return true; + } + } + return false; +} + + +//===----------------------------------------------------------------------===// // Local constant propagation. // From sabre at nondot.org Tue Jun 16 12:23:25 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 17:23:25 -0000 Subject: [llvm-commits] [llvm] r73508 - /llvm/trunk/test/Transforms/InstCombine/select-load-call.ll Message-ID: <200906161723.n5GHNPQA031603@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 12:23:25 2009 New Revision: 73508 URL: http://llvm.org/viewvc/llvm-project?rev=73508&view=rev Log: Testcase for r73506 Added: llvm/trunk/test/Transforms/InstCombine/select-load-call.ll Added: llvm/trunk/test/Transforms/InstCombine/select-load-call.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/select-load-call.ll?rev=73508&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/select-load-call.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/select-load-call.ll Tue Jun 16 12:23:25 2009 @@ -0,0 +1,15 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i32 1} + +declare void @test2() + +define i32 @test(i1 %cond, i32 *%P) { + %A = alloca i32 + store i32 1, i32* %P + store i32 1, i32* %A + + call void @test2() readonly + + %P2 = select i1 %cond, i32 *%P, i32* %A + %V = load i32* %P2 + ret i32 %V +} From gohman at apple.com Tue Jun 16 12:23:50 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 16 Jun 2009 10:23:50 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r73439 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <4A373B0D.8070405@free.fr> References: <200906152305.n5FN5w97012380@zion.cs.uiuc.edu> <4A373B0D.8070405@free.fr> Message-ID: On Jun 15, 2009, at 11:26 PM, Duncan Sands wrote: > Hi Dan, > > >> @@ -3089,6 +3104,8 @@ >> >> Value *TreeToLLVM::EmitNEGATE_EXPR(tree exp, const MemRef *DestLoc) { >> >> if (!DestLoc) { >> >> Value *V = Emit(TREE_OPERAND(exp, 0), 0); >> >> + if (V->getType()->isFPOrFPVector()) >> >> + return Builder.CreateFNeg(V); >> >> if (!isa(V->getType())) >> >> return Builder.CreateNeg(V); >> > > you could also add a CreateAnyNeg builder method that dispatches > to CreateFNeg/CreateNeg appropriately (and likewise for other > operations) to handle this kind of thing. Not sure if this is > really a good idea, but it did strike me that other language > front-ends might find this helpful. I wouldn't object if someone wanted to add such utility routines to IRBuilder. Dan From clattner at apple.com Tue Jun 16 12:32:02 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 16 Jun 2009 10:32:02 -0700 Subject: [llvm-commits] CVS: llvm-www/OpenProjects.html In-Reply-To: <38a0d8450906160435i40749ec2w9cc258e9448479d1@mail.gmail.com> References: <200906160632.n5G6Wqu2027226@zion.cs.uiuc.edu> <38a0d8450906160435i40749ec2w9cc258e9448479d1@mail.gmail.com> Message-ID: On Jun 16, 2009, at 4:35 AM, Rafael Espindola wrote: >> +
  • Value >> + assertions (also PR810> a>).
  • >> > > The example > > int test(char *f) { > if (*f) > __builtin_unreachable (); > return f ? 1 : 0; > } > > > should probably be > > int test(char *f) { > if (*f) > __builtin_unreachable (); > return *f ? 0 : 1; > } > > for it to be reduced to "return 1". That should also be simplified as well. the testcase in the example works because you know that "if *f is 0, that f is not null". -Chris From resistor at mac.com Tue Jun 16 12:33:52 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 17:33:52 -0000 Subject: [llvm-commits] [llvm] r73512 - in /llvm/trunk: include/llvm/Support/ManagedStatic.h include/llvm/Support/Threading.h lib/Support/ManagedStatic.cpp lib/Support/Threading.cpp Message-ID: <200906161733.n5GHXqxK032056@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 12:33:51 2009 New Revision: 73512 URL: http://llvm.org/viewvc/llvm-project?rev=73512&view=rev Log: Split the thread-related APIs out into their own file, and add a few more calls for convenience. Added: llvm/trunk/include/llvm/Support/Threading.h llvm/trunk/lib/Support/Threading.cpp Modified: llvm/trunk/include/llvm/Support/ManagedStatic.h llvm/trunk/lib/Support/ManagedStatic.cpp Modified: llvm/trunk/include/llvm/Support/ManagedStatic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ManagedStatic.h?rev=73512&r1=73511&r2=73512&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ManagedStatic.h (original) +++ llvm/trunk/include/llvm/Support/ManagedStatic.h Tue Jun 16 12:33:51 2009 @@ -15,6 +15,7 @@ #define LLVM_SUPPORT_MANAGED_STATIC_H #include "llvm/System/Atomic.h" +#include "llvm/Support/Threading.h" namespace llvm { @@ -94,13 +95,6 @@ void Register() { RegisterManagedStatic(0, CleanupFn); } }; - -/// llvm_start_multithreaded - Allocate and initialize structures needed to -/// make LLVM safe for multithreading. The return value indicates whether -/// multithreaded initialization succeeded. LLVM will still be operational -/// on "failed" return, but will not be safe to run multithreaded. -bool llvm_start_multithreaded(); - /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm_shutdown(); Added: llvm/trunk/include/llvm/Support/Threading.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Threading.h?rev=73512&view=auto ============================================================================== --- llvm/trunk/include/llvm/Support/Threading.h (added) +++ llvm/trunk/include/llvm/Support/Threading.h Tue Jun 16 12:33:51 2009 @@ -0,0 +1,45 @@ +//===-- llvm/Support/Threading.h - Control multithreading mode --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// TThis file defines llvm_start_multithreaded() and friends. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_THREADING_H +#define LLVM_SUPPORT_THREADING_H + +namespace llvm { + /// llvm_start_multithreaded - Allocate and initialize structures needed to + /// make LLVM safe for multithreading. The return value indicates whether + /// multithreaded initialization succeeded. LLVM will still be operational + /// on "failed" return, and will still be safe for hosting threading + /// applications in the JIT, but will not be safe for concurrent calls to the + /// LLVM APIs. + /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS. + bool llvm_start_multithreaded(); + + /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM + /// safe for multithreading. + /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS. + void llvm_stop_multithreaded(); + + /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe + /// mode or not. + bool llvm_is_multithreaded(); + + /// acquire_global_lock - Acquire the global lock. This is a no-op if called + /// before llvm_start_multithreaded(). + void llvm_acquire_global_lock(); + + /// release_global_lock - Release the global lock. This is a no-op if called + /// before llvm_start_multithreaded(). + void llvm_release_global_lock(); +} + +#endif \ No newline at end of file Modified: llvm/trunk/lib/Support/ManagedStatic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ManagedStatic.cpp?rev=73512&r1=73511&r2=73512&view=diff ============================================================================== --- llvm/trunk/lib/Support/ManagedStatic.cpp (original) +++ llvm/trunk/lib/Support/ManagedStatic.cpp Tue Jun 16 12:33:51 2009 @@ -14,18 +14,15 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Config/config.h" #include "llvm/System/Atomic.h" -#include "llvm/System/Mutex.h" #include using namespace llvm; static const ManagedStaticBase *StaticList = 0; -static sys::Mutex* ManagedStaticMutex = 0; - void ManagedStaticBase::RegisterManagedStatic(void *(*Creator)(), void (*Deleter)(void*)) const { - if (ManagedStaticMutex) { - ManagedStaticMutex->acquire(); + if (llvm_is_multithreaded()) { + llvm_acquire_global_lock(); if (Ptr == 0) { void* tmp = Creator ? Creator() : 0; @@ -39,7 +36,7 @@ StaticList = this; } - ManagedStaticMutex->release(); + llvm_release_global_lock(); } else { assert(Ptr == 0 && DeleterFn == 0 && Next == 0 && "Partially initialized ManagedStatic!?"); @@ -68,24 +65,11 @@ DeleterFn = 0; } -bool llvm::llvm_start_multithreaded() { -#if LLVM_MULTITHREADED - assert(ManagedStaticMutex == 0 && "Multithreaded LLVM already initialized!"); - ManagedStaticMutex = new sys::Mutex(true); - return true; -#else - return false; -#endif -} - /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm::llvm_shutdown() { while (StaticList) StaticList->destroy(); - if (ManagedStaticMutex) { - delete ManagedStaticMutex; - ManagedStaticMutex = 0; - } + if (llvm_is_multithreaded()) llvm_stop_multithreaded(); } Added: llvm/trunk/lib/Support/Threading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Threading.cpp?rev=73512&view=auto ============================================================================== --- llvm/trunk/lib/Support/Threading.cpp (added) +++ llvm/trunk/lib/Support/Threading.cpp Tue Jun 16 12:33:51 2009 @@ -0,0 +1,63 @@ +//===-- llvm/Support/Threading.cpp- Control multithreading mode --*- C++ -*-==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements llvm_start_multithreaded() and friends. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/Threading.h" +#include "llvm/System/Atomic.h" +#include "llvm/System/Mutex.h" +#include + +using namespace llvm; + +static bool multithreaded_mode = false; + +static sys::Mutex* global_lock = 0; + +bool llvm::llvm_start_multithreaded() { +#ifdef LLVM_MULTITHREADED + assert(!multithreaded_mode && "Already multithreaded!"); + multithreaded_mode = true; + global_lock = new sys::Mutex(true); + + // We fence here to ensure that all initialization is complete BEFORE we + // return from llvm_start_multithreaded(). + sys::MemoryFence(); + return true; +#else + return false; +#endif +} + +void llvm::llvm_stop_multithreaded() { +#ifdef LLVM_MULTITHREADED + assert(multithreaded_mode && "Not currently multithreaded!"); + + // We fence here to insure that all threaded operations are complete BEFORE we + // return from llvm_stop_multithreaded(). + sys::MemoryFence(); + + multithreaded_mode = false; + delete global_lock; +#endif +} + +bool llvm::llvm_is_multithreaded() { + return multithreaded_mode; +} + +void llvm::llvm_acquire_global_lock() { + if (multithreaded_mode) global_lock->acquire(); +} + +void llvm::llvm_release_global_lock() { + if (multithreaded_mode) global_lock->release(); +} \ No newline at end of file From resistor at mac.com Tue Jun 16 12:40:28 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 17:40:28 -0000 Subject: [llvm-commits] [llvm] r73515 - /llvm/trunk/docs/ProgrammersManual.html Message-ID: <200906161740.n5GHeTKR032325@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 12:40:28 2009 New Revision: 73515 URL: http://llvm.org/viewvc/llvm-project?rev=73515&view=rev Log: Fix validation errors. Modified: llvm/trunk/docs/ProgrammersManual.html Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=73515&r1=73514&r2=73515&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Tue Jun 16 12:40:28 2009 @@ -2,6 +2,7 @@ "http://www.w3.org/TR/html4/strict.dtd"> + LLVM Programmer's Manual @@ -131,7 +132,7 @@
  • Threads and LLVM @@ -2127,7 +2128,7 @@
    -std::vector params;
    +std::vector<const Type*> params;
     params.push_back(PointerType::getUnqual(Type::Int32Ty));
     FunctionType *ft = FunctionType::get(Type::Int8Ty, params, false);
     
    From dgregor at apple.com Tue Jun 16 12:45:38 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 16 Jun 2009 17:45:38 -0000 Subject: [llvm-commits] [llvm] r73516 - /llvm/trunk/lib/Support/CMakeLists.txt Message-ID: <200906161745.n5GHjcrb032498@zion.cs.uiuc.edu> Author: dgregor Date: Tue Jun 16 12:45:38 2009 New Revision: 73516 URL: http://llvm.org/viewvc/llvm-project?rev=73516&view=rev Log: Add Threading.cpp to the CMake project files Modified: llvm/trunk/lib/Support/CMakeLists.txt Modified: llvm/trunk/lib/Support/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=73516&r1=73515&r2=73516&view=diff ============================================================================== --- llvm/trunk/lib/Support/CMakeLists.txt (original) +++ llvm/trunk/lib/Support/CMakeLists.txt Tue Jun 16 12:45:38 2009 @@ -25,6 +25,7 @@ StringMap.cpp StringPool.cpp SystemUtils.cpp + Threading.cpp Timer.cpp Triple.cpp raw_ostream.cpp From resistor at mac.com Tue Jun 16 13:04:19 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 18:04:19 -0000 Subject: [llvm-commits] [llvm] r73521 - /llvm/trunk/docs/ProgrammersManual.html Message-ID: <200906161804.n5GI4Jto000765@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 13:04:19 2009 New Revision: 73521 URL: http://llvm.org/viewvc/llvm-project?rev=73521&view=rev Log: Update the threading section to reflect current plans/implementation. Modified: llvm/trunk/docs/ProgrammersManual.html Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=73521&r1=73520&r2=73521&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Tue Jun 16 13:04:19 2009 @@ -132,7 +132,8 @@
  • Threads and LLVM @@ -2172,27 +2173,38 @@

    In order to properly protect its internal data structures while avoiding -excessive locking overhead in the single-threaded case, the LLVM APIs require -that the client invoke llvm_start_multithreaded(). This call must -complete before any other threads attempt to invoke LLVM APIs. Any -attempts to call LLVM APIs from multiple threads before -llvm_start_multithreaded returns can and will cause corruption of -LLVM's internal data. +excessive locking overhead in the single-threaded case, the LLVM must intialize +certain data structures necessary to provide guards around its internals. To do +so, the client program must invoke llvm_start_multithreaded() before +making any concurrent LLVM API calls. To subsequently tear down these +structures, use the llvm_stop_multithreaded() call. You can also use +the llvm_is_multithreaded() call to check the status of multithreaded +mode.

    -A caveat: before llvm_start_multithreaded() has been invoked, all -llvm::sys::Mutex acquisitions and releases will become no-ops. This -means that llvm_start_multithreaded() must be invoked before a threaded -application can be executed in the JIT. +Note that both of these calls must be made in isolation. That is to +say that no other LLVM API calls may be executing at any time during the +execution of llvm_start_multithreaded() or llvm_stop_multithreaded +. It's is the client's responsibility to enforce this isolation. +

    + +

    +The return value of llvm_start_multithreaded() indicates the success or +failure of the initialization. Failure typically indicates that your copy of +LLVM was built without multithreading support, typically because GCC atomic +intrinsics were not found in your system compiler. In this case, the LLVM API +will not be safe for concurrent calls. However, it will be safe for +hosting threaded applications in the JIT, though care must be taken to ensure +that side exits and the like do not accidentally result in concurrent LLVM API +calls.

    @@ -2204,9 +2216,10 @@

    When you are done using the LLVM APIs, you should call llvm_shutdown() -to deallocate memory used for internal structures. This call must not begin -while any other threads are still issuing LLVM API calls. Doing so is likely -to result in garbage data or crashes. +to deallocate memory used for internal structures. This will also invoke +llvm_stop_multithreaded() if LLVM is operating in multithreaded mode. +As such, llvm_shutdown() requires the same isolation guarantees as +llvm_stop_multithreaded().

    @@ -2235,6 +2248,13 @@ llvm_start_multithreaded() returns, it is possible to have ManagedStatics of llvm::sys::Mutexs.

    + +

    +The llvm_acquire_global_lock() and llvm_release_global_lock +APIs provide access to the global lock used to implement the double-checked +locking for lazy initialization. These should only be used internally to LLVM, +and only if you know what you're doing! +

    From resistor at mac.com Tue Jun 16 13:20:21 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 18:20:21 -0000 Subject: [llvm-commits] [llvm] r73523 - in /llvm/trunk: autoconf/configure.ac configure include/llvm/Config/config.h.in Message-ID: <200906161820.n5GIKNvI001506@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 13:20:20 2009 New Revision: 73523 URL: http://llvm.org/viewvc/llvm-project?rev=73523&view=rev Log: Add a configure check for pthread_rwlock_init. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/configure llvm/trunk/include/llvm/Config/config.h.in Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=73523&r1=73522&r2=73523&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Tue Jun 16 13:20:20 2009 @@ -796,6 +796,9 @@ AC_SEARCH_LIBS(pthread_mutex_lock,pthread, AC_DEFINE([HAVE_PTHREAD_MUTEX_LOCK],[1], [Have pthread_mutex_lock])) + AC_SEARCH_LIBS(pthread_rwlock_init,pthread, + AC_DEFINE([HAVE_PTHREAD_RWLOCK_INIT],[1], + [Have pthread_rwlock_init])) fi dnl Allow extra x86-disassembler library Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=73523&r1=73522&r2=73523&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Tue Jun 16 13:20:20 2009 @@ -27896,6 +27896,109 @@ fi + { echo "$as_me:$LINENO: checking for library containing pthread_rwlock_init" >&5 +echo $ECHO_N "checking for library containing pthread_rwlock_init... $ECHO_C" >&6; } +if test "${ac_cv_search_pthread_rwlock_init+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pthread_rwlock_init (); +int +main () +{ +return pthread_rwlock_init (); + ; + return 0; +} +_ACEOF +for ac_lib in '' pthread; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +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_link") 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_exeext' + { (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 + ac_cv_search_pthread_rwlock_init=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_pthread_rwlock_init+set}" = set; then + break +fi +done +if test "${ac_cv_search_pthread_rwlock_init+set}" = set; then + : +else + ac_cv_search_pthread_rwlock_init=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_pthread_rwlock_init" >&5 +echo "${ECHO_T}$ac_cv_search_pthread_rwlock_init" >&6; } +ac_res=$ac_cv_search_pthread_rwlock_init +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +cat >>confdefs.h <<\_ACEOF +#define HAVE_PTHREAD_RWLOCK_INIT 1 +_ACEOF + +fi + fi 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=73523&r1=73522&r2=73523&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.in (original) +++ llvm/trunk/include/llvm/Config/config.h.in Tue Jun 16 13:20:20 2009 @@ -285,6 +285,9 @@ /* Have pthread_mutex_lock */ #undef HAVE_PTHREAD_MUTEX_LOCK +/* Have pthread_rwlock_init */ +#undef HAVE_PTHREAD_RWLOCK_INIT + /* Define to 1 if srand48/lrand48/drand48 exist in */ #undef HAVE_RAND48 From espindola at google.com Tue Jun 16 13:47:43 2009 From: espindola at google.com (Rafael Espindola) Date: Tue, 16 Jun 2009 19:47:43 +0100 Subject: [llvm-commits] CVS: llvm-www/OpenProjects.html In-Reply-To: References: <200906160632.n5G6Wqu2027226@zion.cs.uiuc.edu> <38a0d8450906160435i40749ec2w9cc258e9448479d1@mail.gmail.com> Message-ID: <38a0d8450906161147p32bbec2aub03864802e1e51db@mail.gmail.com> > That should also be simplified as well. ?the testcase in the example > works because you know that "if *f is 0, that f is not null". But we don't need __builtin_unreachable for that, do we? Can void g(char); int test(char *f) { g (*f); return f ? 1 : 0; } be simplified to "return 1"? > -Chris Cheers, -- Rafael Avila de Espindola Google | Gordon House | Barrow Street | Dublin 4 | Ireland Registered in Dublin, Ireland | Registration Number: 368047 From asl at math.spbu.ru Tue Jun 16 13:49:09 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 16 Jun 2009 18:49:09 -0000 Subject: [llvm-commits] [llvm] r73529 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.cpp test/CodeGen/ARM/vargs2.ll Message-ID: <200906161849.n5GIn9sD002423@zion.cs.uiuc.edu> Author: asl Date: Tue Jun 16 13:49:08 2009 New Revision: 73529 URL: http://llvm.org/viewvc/llvm-project?rev=73529&view=rev Log: GNU as refuses to assemble "pop {}" instruction. Do not emit such (this is the case when we have thumb vararg function with single callee-saved register, which is handled separately). Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp llvm/trunk/test/CodeGen/ARM/vargs2.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=73529&r1=73528&r2=73529&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Tue Jun 16 13:49:08 2009 @@ -697,7 +697,6 @@ bool isVarArg = AFI->getVarArgsRegSaveSize() > 0; MachineInstr *PopMI = MF.CreateMachineInstr(get(ARM::tPOP),MI->getDebugLoc()); - MBB.insert(MI, PopMI); for (unsigned i = CSI.size(); i != 0; --i) { unsigned Reg = CSI[i-1].getReg(); if (Reg == ARM::LR) { @@ -706,10 +705,15 @@ continue; Reg = ARM::PC; PopMI->setDesc(get(ARM::tPOP_RET)); - MBB.erase(MI); + MI = MBB.erase(MI); } PopMI->addOperand(MachineOperand::CreateReg(Reg, true)); } + + // It's illegal to emit pop instruction without operands. + if (PopMI->getNumOperands() > 0) + MBB.insert(MI, PopMI); + return true; } Modified: llvm/trunk/test/CodeGen/ARM/vargs2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vargs2.ll?rev=73529&r1=73528&r2=73529&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vargs2.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vargs2.ll Tue Jun 16 13:49:08 2009 @@ -1,6 +1,6 @@ ; RUN: llvm-as < %s | llc -march=thumb ; RUN: llvm-as < %s | llc -march=thumb | \ -; RUN: grep pop | count 2 +; RUN: grep pop | count 1 @str = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1] From asl at math.spbu.ru Tue Jun 16 13:50:49 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 16 Jun 2009 18:50:49 -0000 Subject: [llvm-commits] [llvm] r73530 - in /llvm/trunk: include/llvm/CallingConv.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/ARM/ARMCallingConv.td lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h lib/VMCore/AsmWriter.cpp Message-ID: <200906161850.n5GIooUi002500@zion.cs.uiuc.edu> Author: asl Date: Tue Jun 16 13:50:49 2009 New Revision: 73530 URL: http://llvm.org/viewvc/llvm-project?rev=73530&view=rev Log: Address review comments: add 3 ARM calling conventions. Dispatch C calling conv. to one of these conventions based on target triple and subtarget features. Modified: llvm/trunk/include/llvm/CallingConv.h llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLToken.h llvm/trunk/lib/Target/ARM/ARMCallingConv.td llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/include/llvm/CallingConv.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CallingConv.h?rev=73530&r1=73529&r2=73530&view=diff ============================================================================== --- llvm/trunk/include/llvm/CallingConv.h (original) +++ llvm/trunk/include/llvm/CallingConv.h Tue Jun 16 13:50:49 2009 @@ -57,7 +57,18 @@ /// X86_FastCall - 'fast' analog of X86_StdCall. Passes first two arguments /// in ECX:EDX registers, others - via stack. Callee is responsible for /// stack cleaning. - X86_FastCall = 65 + X86_FastCall = 65, + + /// ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete, + /// but still used on some targets). + ARM_APCS = 66, + + /// ARM_AAPCS - ARM Architecture Procedure Calling Standard calling + /// convention (aka EABI). Soft float variant. + ARM_AAPCS = 67, + + /// ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI. + ARM_AAPCS_VFP = 68 }; } // End CallingConv namespace Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=73530&r1=73529&r2=73530&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Tue Jun 16 13:50:49 2009 @@ -526,6 +526,10 @@ KEYWORD(coldcc); KEYWORD(x86_stdcallcc); KEYWORD(x86_fastcallcc); + KEYWORD(arm_apcscc); + KEYWORD(arm_aapcscc); + KEYWORD(arm_aapcs_vfpcc); + KEYWORD(cc); KEYWORD(c); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=73530&r1=73529&r2=73530&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Jun 16 13:50:49 2009 @@ -808,8 +808,11 @@ /// ::= 'coldcc' /// ::= 'x86_stdcallcc' /// ::= 'x86_fastcallcc' +/// ::= 'arm_apcscc' +/// ::= 'arm_aapcscc' +/// ::= 'arm_aapcs_vfpcc' /// ::= 'cc' UINT -/// +/// bool LLParser::ParseOptionalCallingConv(unsigned &CC) { switch (Lex.getKind()) { default: CC = CallingConv::C; return false; @@ -818,6 +821,9 @@ case lltok::kw_coldcc: CC = CallingConv::Cold; break; case lltok::kw_x86_stdcallcc: CC = CallingConv::X86_StdCall; break; case lltok::kw_x86_fastcallcc: CC = CallingConv::X86_FastCall; break; + case lltok::kw_arm_apcscc: CC = CallingConv::ARM_APCS; break; + case lltok::kw_arm_aapcscc: CC = CallingConv::ARM_AAPCS; break; + case lltok::kw_arm_aapcs_vfpcc:CC = CallingConv::ARM_AAPCS_VFP; break; case lltok::kw_cc: Lex.Lex(); return ParseUInt32(CC); } Lex.Lex(); Modified: llvm/trunk/lib/AsmParser/LLToken.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=73530&r1=73529&r2=73530&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLToken.h (original) +++ llvm/trunk/lib/AsmParser/LLToken.h Tue Jun 16 13:50:49 2009 @@ -60,7 +60,9 @@ kw_gc, kw_c, - kw_cc, kw_ccc, kw_fastcc, kw_coldcc, kw_x86_stdcallcc, kw_x86_fastcallcc, + kw_cc, kw_ccc, kw_fastcc, kw_coldcc, + kw_x86_stdcallcc, kw_x86_fastcallcc, + kw_arm_apcscc, kw_arm_aapcscc, kw_arm_aapcs_vfpcc, kw_signext, kw_zeroext, Modified: llvm/trunk/lib/Target/ARM/ARMCallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCallingConv.td?rev=73530&r1=73529&r2=73530&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCallingConv.td (original) +++ llvm/trunk/lib/Target/ARM/ARMCallingConv.td Tue Jun 16 13:50:49 2009 @@ -17,11 +17,6 @@ class CCIfAlign: CCIf; -/// CCIfFloatABI - Match of the float ABI and the arg. ABIType may be "Hard" or -/// "Soft". -class CCIfFloatABI: - CCIf; - //===----------------------------------------------------------------------===// // ARM APCS Calling Convention //===----------------------------------------------------------------------===// @@ -105,25 +100,3 @@ S9, S10, S11, S12, S13, S14, S15]>>, CCDelegateTo ]>; - -//===----------------------------------------------------------------------===// -// ARM Calling Convention Dispatch -//===----------------------------------------------------------------------===// - -def CC_ARM : CallingConv<[ - CCIfSubtarget<"isAAPCS_ABI()", - CCIfSubtarget<"hasVFP2()", - CCIfFloatABI<"Hard", - CCDelegateTo>>>, - CCIfSubtarget<"isAAPCS_ABI()", CCDelegateTo>, - CCDelegateTo -]>; - -def RetCC_ARM : CallingConv<[ - CCIfSubtarget<"isAAPCS_ABI()", - CCIfSubtarget<"hasVFP2()", - CCIfFloatABI<"Hard", - CCDelegateTo>>>, - CCIfSubtarget<"isAAPCS_ABI()", CCDelegateTo>, - CCDelegateTo -]>; Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=73530&r1=73529&r2=73530&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Jun 16 13:50:49 2009 @@ -415,7 +415,7 @@ ARM::NoRegister }; unsigned Reg = State.AllocateReg(HiRegList, LoRegList, 4); - if (Reg == 0) + if (Reg == 0) return false; // we didn't handle it unsigned i; @@ -487,6 +487,33 @@ State); } +/// CCAssignFnForNode - Selects the correct CCAssignFn for a the +/// given CallingConvention value. +CCAssignFn *ARMTargetLowering::CCAssignFnForNode(unsigned CC, + bool Return) const { + switch (CC) { + default: + assert(0 && "Unsupported calling convention"); + case CallingConv::C: + case CallingConv::Fast: + // Use target triple & subtarget features to do actual dispatch. + if (Subtarget->isAAPCS_ABI()) { + if (Subtarget->hasVFP2() && + FloatABIType == FloatABI::Hard) + return (Return ? RetCC_ARM_AAPCS_VFP: CC_ARM_AAPCS_VFP); + else + return (Return ? RetCC_ARM_AAPCS: CC_ARM_AAPCS); + } else + return (Return ? RetCC_ARM_APCS: CC_ARM_APCS); + case CallingConv::ARM_AAPCS_VFP: + return (Return ? RetCC_ARM_AAPCS_VFP: CC_ARM_AAPCS_VFP); + case CallingConv::ARM_AAPCS: + return (Return ? RetCC_ARM_AAPCS: CC_ARM_AAPCS); + case CallingConv::ARM_APCS: + return (Return ? RetCC_ARM_APCS: CC_ARM_APCS); + } +} + /// LowerCallResult - Lower the result values of an ISD::CALL into the /// appropriate copies out of appropriate physical registers. This assumes that /// Chain/InFlag are the input chain/flag to use, and that TheCall is the call @@ -501,7 +528,8 @@ SmallVector RVLocs; bool isVarArg = TheCall->isVarArg(); CCState CCInfo(CallingConv, isVarArg, getTargetMachine(), RVLocs); - CCInfo.AnalyzeCallResult(TheCall, RetCC_ARM); + CCInfo.AnalyzeCallResult(TheCall, + CCAssignFnForNode(CallingConv, /* Return*/ true)); SmallVector ResultVals; @@ -586,8 +614,6 @@ MVT RetVT = TheCall->getRetValType(0); SDValue Chain = TheCall->getChain(); unsigned CC = TheCall->getCallingConv(); - assert((CC == CallingConv::C || - CC == CallingConv::Fast) && "unknown calling convention"); bool isVarArg = TheCall->isVarArg(); SDValue Callee = TheCall->getCallee(); DebugLoc dl = TheCall->getDebugLoc(); @@ -595,7 +621,7 @@ // Analyze operands of the call, assigning locations to each operand. SmallVector ArgLocs; CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs); - CCInfo.AnalyzeCallOperands(TheCall, CC_ARM); + CCInfo.AnalyzeCallOperands(TheCall, CCAssignFnForNode(CC, /* Return*/ false)); // Get a count of how many bytes are to be pushed on the stack. unsigned NumBytes = CCInfo.getNextStackOffset(); @@ -788,7 +814,7 @@ CCState CCInfo(CC, isVarArg, getTargetMachine(), RVLocs); // Analyze return values of ISD::RET. - CCInfo.AnalyzeReturn(Op.getNode(), RetCC_ARM); + CCInfo.AnalyzeReturn(Op.getNode(), CCAssignFnForNode(CC, /* Return */ true)); // If this is the first return lowered for this function, add // the regs to the liveout set for the function. @@ -1085,7 +1111,8 @@ // Assign locations to all of the incoming arguments. SmallVector ArgLocs; CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs); - CCInfo.AnalyzeFormalArguments(Op.getNode(), CC_ARM); + CCInfo.AnalyzeFormalArguments(Op.getNode(), + CCAssignFnForNode(CC, /* Return*/ false)); SmallVector ArgValues; Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=73530&r1=73529&r2=73530&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Tue Jun 16 13:50:49 2009 @@ -151,6 +151,7 @@ /// unsigned ARMPCLabelIndex; + CCAssignFn *CCAssignFnForNode(unsigned CC, bool Return) const; SDValue LowerMemOpCallTo(CallSDNode *TheCall, SelectionDAG &DAG, const SDValue &StackPtr, const CCValAssign &VA, SDValue Chain, SDValue Arg, ISD::ArgFlagsTy Flags); Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=73530&r1=73529&r2=73530&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Jun 16 13:50:49 2009 @@ -1384,7 +1384,10 @@ case CallingConv::Fast: Out << "fastcc "; break; case CallingConv::Cold: Out << "coldcc "; break; case CallingConv::X86_StdCall: Out << "x86_stdcallcc "; break; - case CallingConv::X86_FastCall: Out << "x86_fastcallcc "; break; + case CallingConv::X86_FastCall: Out << "x86_fastcallcc "; break; + case CallingConv::ARM_APCS: Out << "arm_apcscc "; break; + case CallingConv::ARM_AAPCS: Out << "arm_aapcscc "; break; + case CallingConv::ARM_AAPCS_VFP:Out << "arm_aapcs_vfpcc "; break; default: Out << "cc" << F->getCallingConv() << " "; break; } @@ -1640,7 +1643,10 @@ case CallingConv::Fast: Out << " fastcc"; break; case CallingConv::Cold: Out << " coldcc"; break; case CallingConv::X86_StdCall: Out << " x86_stdcallcc"; break; - case CallingConv::X86_FastCall: Out << " x86_fastcallcc"; break; + case CallingConv::X86_FastCall: Out << " x86_fastcallcc"; break; + case CallingConv::ARM_APCS: Out << " arm_apcscc "; break; + case CallingConv::ARM_AAPCS: Out << " arm_aapcscc "; break; + case CallingConv::ARM_AAPCS_VFP:Out << " arm_aapcs_vfpcc "; break; default: Out << " cc" << CI->getCallingConv(); break; } @@ -1688,6 +1694,9 @@ case CallingConv::Cold: Out << " coldcc"; break; case CallingConv::X86_StdCall: Out << " x86_stdcallcc"; break; case CallingConv::X86_FastCall: Out << " x86_fastcallcc"; break; + case CallingConv::ARM_APCS: Out << " arm_apcscc "; break; + case CallingConv::ARM_AAPCS: Out << " arm_aapcscc "; break; + case CallingConv::ARM_AAPCS_VFP:Out << " arm_aapcs_vfpcc "; break; default: Out << " cc" << II->getCallingConv(); break; } From asl at math.spbu.ru Tue Jun 16 13:53:18 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 16 Jun 2009 18:53:18 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73531 - /llvm-gcc-4.2/trunk/gcc/config.gcc Message-ID: <200906161853.n5GIrIud002600@zion.cs.uiuc.edu> Author: asl Date: Tue Jun 16 13:53:18 2009 New Revision: 73531 URL: http://llvm.org/viewvc/llvm-project?rev=73531&view=rev Log: Add armv7-a to possible list of -with-arch configure options Modified: llvm-gcc-4.2/trunk/gcc/config.gcc Modified: llvm-gcc-4.2/trunk/gcc/config.gcc URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config.gcc?rev=73531&r1=73530&r2=73531&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config.gcc (original) +++ llvm-gcc-4.2/trunk/gcc/config.gcc Tue Jun 16 13:53:18 2009 @@ -2779,11 +2779,14 @@ fi done + # LLVM LOCAL begin case "$with_arch" in "" \ | armv[23456] | armv2a | armv3m | armv4t | armv5t \ | armv5te | armv6j |armv6k | armv6z | armv6zk \ + | armv7-a \ | iwmmxt | ep9312) + # LLVM LOCAL end # OK ;; *) From asl at math.spbu.ru Tue Jun 16 13:53:48 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 16 Jun 2009 18:53:48 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73532 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h Message-ID: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> Author: asl Date: Tue Jun 16 13:53:48 2009 New Revision: 73532 URL: http://llvm.org/viewvc/llvm-project?rev=73532&view=rev Log: Generate new ARM calling conventions depending on options, etc. Added: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=73532&r1=73531&r2=73532&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Tue Jun 16 13:53:48 2009 @@ -36,6 +36,15 @@ #endif /* LLVM LOCAL end */ #endif + +/* LLVM LOCAL begin */ +#ifdef ENABLE_LLVM +/* Add general target specific stuff */ +#include "llvm-arm-target.h" + +#endif /* ENABLE_LLVM */ +/* LLVM LOCAL end */ + /* APPLE LOCAL end ARM darwin target */ /* APPLE LOCAL ARM interworking */ Added: 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=73532&view=auto ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h (added) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Tue Jun 16 13:53:48 2009 @@ -0,0 +1,36 @@ +/* LLVM LOCAL begin (ENTIRE FILE!) */ +#ifdef ENABLE_LLVM +/* Some target-specific hooks for gcc->llvm conversion +Copyright (C) 2009 Free Software Foundation, Inc. +Contributed by Anton Korobeynikov (asl at math.spbu.ru) + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ + +/* LLVM specific stuff for supporting calling convention output */ +#define TARGET_ADJUST_LLVM_CC(CC, type) \ + { \ + if (TARGET_AAPCS_BASED) \ + CC = (TARGET_VFP && TARGET_HARD_FLOAT_ABI ? \ + CallingConv::ARM_AAPCS_VFP : \ + CallingConv::ARM_AAPCS); \ + else \ + CC = CallingConv::ARM_APCS; \ + } + +#endif /* ENABLE_LLVM */ +/* LLVM LOCAL end (ENTIRE FILE!) */ From tonic at nondot.org Tue Jun 16 14:21:30 2009 From: tonic at nondot.org (Tanya Lattner) Date: Tue, 16 Jun 2009 14:21:30 -0500 Subject: [llvm-commits] CVS: llvm-www/www-index.html Message-ID: <200906161921.n5GJLUpc003642@zion.cs.uiuc.edu> Changes in directory llvm-www: www-index.html updated: 1.176 -> 1.177 --- Log message: Add 2.6 release schedule. --- Diffs of the changes: (+6 -1) www-index.html | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletion(-) Index: llvm-www/www-index.html diff -u llvm-www/www-index.html:1.176 llvm-www/www-index.html:1.177 --- llvm-www/www-index.html:1.176 Tue Mar 3 00:47:02 2009 +++ llvm-www/www-index.html Tue Jun 16 14:18:24 2009 @@ -106,7 +106,12 @@

    LLVM 2.6 release schedule:

      -
    • TBD
    • +
    • Aug 21 - Code Freeze
    • +
    • Aug 28 - Pre-release1 testing begins
    • +
    • Sept 04 - Pre-release1 testing ends
    • +
    • Sept 11 - Pre-release2 testing begins
    • +
    • Sept 18 - Pre-release2 testing ends
    • +
    • Sept 21 - Release!
    From evan.cheng at apple.com Tue Jun 16 14:44:27 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 16 Jun 2009 19:44:27 -0000 Subject: [llvm-commits] [llvm] r73536 - /llvm/trunk/lib/Target/X86/X86Instr64bit.td Message-ID: <200906161944.n5GJiRcL004517@zion.cs.uiuc.edu> Author: evancheng Date: Tue Jun 16 14:44:27 2009 New Revision: 73536 URL: http://llvm.org/viewvc/llvm-project?rev=73536&view=rev Log: CALL64pcrel32 immediate field is 32-bit. Patch by Abhinav Duggal. Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=73536&r1=73535&r2=73536&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Tue Jun 16 14:44:27 2009 @@ -113,7 +113,7 @@ // NOTE: this pattern doesn't match "X86call imm", because we do not know // that the offset between an arbitrary immediate and the call will fit in // the 32-bit pcrel field that we have. - def CALL64pcrel32 : I<0xE8, RawFrm, + def CALL64pcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i64i32imm:$dst, variable_ops), "call\t${dst:call}", []>, Requires<[In64BitMode]>; From gohman at apple.com Tue Jun 16 14:52:01 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 16 Jun 2009 19:52:01 -0000 Subject: [llvm-commits] [llvm] r73540 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Transforms/IndVarSimplify/shrunk-constant.ll Message-ID: <200906161952.n5GJq2uT005317@zion.cs.uiuc.edu> Author: djg Date: Tue Jun 16 14:52:01 2009 New Revision: 73540 URL: http://llvm.org/viewvc/llvm-project?rev=73540&view=rev Log: Instcombine's ShrinkDemandedConstant may strip bits out of constants, obscuring what would otherwise be a low-bits mask. Use ComputeMaskedBits to compute what ShrinkDemandedConstant knew about to reconstruct a low-bits mask value. Added: llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.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=73540&r1=73539&r2=73540&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Jun 16 14:52:01 2009 @@ -68,6 +68,7 @@ #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/LoopInfo.h" +#include "llvm/Analysis/ValueTracking.h" #include "llvm/Assembly/Writer.h" #include "llvm/Target/TargetData.h" #include "llvm/Support/CommandLine.h" @@ -2394,14 +2395,28 @@ if (CI->isAllOnesValue()) return getSCEV(U->getOperand(0)); const APInt &A = CI->getValue(); - unsigned Ones = A.countTrailingOnes(); - if (APIntOps::isMask(Ones, A)) + + // Instcombine's ShrinkDemandedConstant may strip bits out of + // constants, obscuring what would otherwise be a low-bits mask. + // Use ComputeMaskedBits to compute what ShrinkDemandedConstant + // knew about to reconstruct a low-bits mask value. + unsigned LZ = A.countLeadingZeros(); + unsigned BitWidth = A.getBitWidth(); + APInt AllOnes = APInt::getAllOnesValue(BitWidth); + APInt KnownZero(BitWidth, 0), KnownOne(BitWidth, 0); + ComputeMaskedBits(U->getOperand(0), AllOnes, KnownZero, KnownOne, TD); + + APInt EffectiveMask = APInt::getLowBitsSet(BitWidth, BitWidth - LZ); + + if (LZ != 0 && !((~A & ~KnownZero) & EffectiveMask)) { return getZeroExtendExpr(getTruncateExpr(getSCEV(U->getOperand(0)), - IntegerType::get(Ones)), + IntegerType::get(BitWidth - LZ)), U->getType()); + } } break; + case Instruction::Or: // If the RHS of the Or is a constant, we may have something like: // X*4+1 which got turned into X*4|1. Handle this as an Add so loop Added: llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll?rev=73540&view=auto ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll (added) +++ llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll Tue Jun 16 14:52:01 2009 @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | opt -iv-users -analyze | grep store + +define fastcc void @foo() nounwind { +entry: + br label %loop + +loop: + %i = phi i32 [ 0, %entry ], [ %t2, %loop ] + %t0 = add i32 %i, 9 + %t1 = and i32 %t0, 9 + store i32 %t1, i32* null + %t2 = add i32 %i, 8 + br label %loop +} From gohman at apple.com Tue Jun 16 14:55:30 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 16 Jun 2009 19:55:30 -0000 Subject: [llvm-commits] [llvm] r73541 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/vector-casts-0.ll test/Transforms/InstCombine/vector-casts-1.ll test/Transforms/InstCombine/vector-casts.ll Message-ID: <200906161955.n5GJtUaW005454@zion.cs.uiuc.edu> Author: djg Date: Tue Jun 16 14:55:29 2009 New Revision: 73541 URL: http://llvm.org/viewvc/llvm-project?rev=73541&view=rev Log: Generalize a few more instcombines to be vector/scalar-independent. Added: llvm/trunk/test/Transforms/InstCombine/vector-casts-0.ll (props changed) - copied unchanged from r73467, llvm/trunk/test/Transforms/InstCombine/vector-casts.ll llvm/trunk/test/Transforms/InstCombine/vector-casts-1.ll Removed: llvm/trunk/test/Transforms/InstCombine/vector-casts.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=73541&r1=73540&r2=73541&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jun 16 14:55:29 2009 @@ -5967,9 +5967,9 @@ unsigned BitWidth = 0; if (TD) - BitWidth = TD->getTypeSizeInBits(Ty); - else if (isa(Ty)) - BitWidth = Ty->getPrimitiveSizeInBits(); + BitWidth = TD->getTypeSizeInBits(Ty->getScalarType()); + else if (Ty->isIntOrIntVector()) + BitWidth = Ty->getScalarSizeInBits(); bool isSignBit = false; @@ -7234,18 +7234,16 @@ if (ConstantInt *CSI = dyn_cast(Op0)) if (CSI->isAllOnesValue()) return ReplaceInstUsesWith(I, CSI); - + // See if we can turn a signed shr into an unsigned shr. - if (!isa(I.getType())) { - if (MaskedValueIsZero(Op0, - APInt::getSignBit(I.getType()->getPrimitiveSizeInBits()))) - return BinaryOperator::CreateLShr(Op0, I.getOperand(1)); - - // Arithmetic shifting an all-sign-bit value is a no-op. - unsigned NumSignBits = ComputeNumSignBits(Op0); - if (NumSignBits == Op0->getType()->getPrimitiveSizeInBits()) - return ReplaceInstUsesWith(I, Op0); - } + if (MaskedValueIsZero(Op0, + APInt::getSignBit(I.getType()->getScalarSizeInBits()))) + return BinaryOperator::CreateLShr(Op0, I.getOperand(1)); + + // Arithmetic shifting an all-sign-bit value is a no-op. + unsigned NumSignBits = ComputeNumSignBits(Op0); + if (NumSignBits == Op0->getType()->getScalarSizeInBits()) + return ReplaceInstUsesWith(I, Op0); return 0; } @@ -7295,7 +7293,7 @@ // See if we can simplify any instructions used by the instruction whose sole // purpose is to compute bits we don't care about. - uint32_t TypeBits = Op0->getType()->getPrimitiveSizeInBits(); + uint32_t TypeBits = Op0->getType()->getScalarSizeInBits(); // shl i32 X, 32 = 0 and srl i8 Y, 9 = 0, ... just don't eliminate // a signed shift. @@ -7344,8 +7342,8 @@ // part of the register be zeros. Emulate this by inserting an AND to // clear the top bits as needed. This 'and' will usually be zapped by // other xforms later if dead. - unsigned SrcSize = TrOp->getType()->getPrimitiveSizeInBits(); - unsigned DstSize = TI->getType()->getPrimitiveSizeInBits(); + unsigned SrcSize = TrOp->getType()->getScalarSizeInBits(); + unsigned DstSize = TI->getType()->getScalarSizeInBits(); APInt MaskV(APInt::getLowBitsSet(SrcSize, DstSize)); // The mask we constructed says what the trunc would do if occurring @@ -8380,7 +8378,8 @@ uint32_t SrcBitWidth = Src->getType()->getScalarSizeInBits(); // Canonicalize trunc x to i1 -> (icmp ne (and x, 1), 0) - if (!isa(Ty) && DestBitWidth == 1) { + if (DestBitWidth == 1 && + isa(Ty) == isa(Src->getType())) { Constant *One = ConstantInt::get(Src->getType(), 1); Src = InsertNewInstBefore(BinaryOperator::CreateAnd(Src, One, "tmp"), CI); Value *Zero = Constant::getNullValue(Src->getType()); Propchange: llvm/trunk/test/Transforms/InstCombine/vector-casts-0.ll ------------------------------------------------------------------------------ svn:mergeinfo = Added: llvm/trunk/test/Transforms/InstCombine/vector-casts-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vector-casts-1.ll?rev=73541&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/vector-casts-1.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/vector-casts-1.ll Tue Jun 16 14:55:29 2009 @@ -0,0 +1,15 @@ +; RUN: llvm-as < %s | opt -instcombine > %t +; RUN: not grep trunc %t +; RUN: not grep ashr %t + +; This turns into a&1 != 0 +define <2 x i1> @a(<2 x i64> %a) { + %t = trunc <2 x i64> %a to <2 x i1> + ret <2 x i1> %t +} +; The ashr turns into an lshr. +define <2 x i64> @b(<2 x i64> %a) { + %b = and <2 x i64> %a, + %t = ashr <2 x i64> %b, + ret <2 x i64> %t +} Removed: llvm/trunk/test/Transforms/InstCombine/vector-casts.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vector-casts.ll?rev=73540&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/vector-casts.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/vector-casts.ll (removed) @@ -1,55 +0,0 @@ -; RUN: llvm-as < %s | opt -instcombine - -define void @convert(<2 x i32>* %dst.addr, <2 x i64> %src) nounwind { -entry: - %val = trunc <2 x i64> %src to <2 x i32> ; <<2 x i32>> [#uses=1] - %add = add <2 x i32> %val, ; <<2 x i32>> [#uses=1] - store <2 x i32> %add, <2 x i32>* %dst.addr - ret void -} - -define <2 x i65> @foo(<2 x i64> %t) { - %a = trunc <2 x i64> %t to <2 x i32> - %b = zext <2 x i32> %a to <2 x i65> - ret <2 x i65> %b -} -define <2 x i64> @bar(<2 x i65> %t) { - %a = trunc <2 x i65> %t to <2 x i32> - %b = zext <2 x i32> %a to <2 x i64> - ret <2 x i64> %b -} -define <2 x i65> @foos(<2 x i64> %t) { - %a = trunc <2 x i64> %t to <2 x i32> - %b = sext <2 x i32> %a to <2 x i65> - ret <2 x i65> %b -} -define <2 x i64> @bars(<2 x i65> %t) { - %a = trunc <2 x i65> %t to <2 x i32> - %b = sext <2 x i32> %a to <2 x i64> - ret <2 x i64> %b -} -define <2 x i64> @quxs(<2 x i64> %t) { - %a = trunc <2 x i64> %t to <2 x i32> - %b = sext <2 x i32> %a to <2 x i64> - ret <2 x i64> %b -} -define <2 x i64> @quxt(<2 x i64> %t) { - %a = shl <2 x i64> %t, - %b = ashr <2 x i64> %a, - ret <2 x i64> %b -} -define <2 x double> @fa(<2 x double> %t) { - %a = fptrunc <2 x double> %t to <2 x float> - %b = fpext <2 x float> %a to <2 x double> - ret <2 x double> %b -} -define <2 x double> @fb(<2 x double> %t) { - %a = fptoui <2 x double> %t to <2 x i64> - %b = uitofp <2 x i64> %a to <2 x double> - ret <2 x double> %b -} -define <2 x double> @fc(<2 x double> %t) { - %a = fptosi <2 x double> %t to <2 x i64> - %b = sitofp <2 x i64> %a to <2 x double> - ret <2 x double> %b -} From clattner at apple.com Tue Jun 16 14:59:35 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 16 Jun 2009 12:59:35 -0700 Subject: [llvm-commits] CVS: llvm-www/OpenProjects.html In-Reply-To: <38a0d8450906161147p32bbec2aub03864802e1e51db@mail.gmail.com> References: <200906160632.n5G6Wqu2027226@zion.cs.uiuc.edu> <38a0d8450906160435i40749ec2w9cc258e9448479d1@mail.gmail.com> <38a0d8450906161147p32bbec2aub03864802e1e51db@mail.gmail.com> Message-ID: <7A2A6F99-DF49-470C-A02D-55F7C00B4C4C@apple.com> On Jun 16, 2009, at 11:47 AM, Rafael Espindola wrote: >> That should also be simplified as well. the testcase in the example >> works because you know that "if *f is 0, that f is not null". > > But we don't need __builtin_unreachable for that, do we? Can > > void g(char); > int test(char *f) { > g (*f); > return f ? 1 : 0; > } > > be simplified to "return 1"? Yes, you're right. I'll fix the example, thanks! -Chris From bob.wilson at apple.com Tue Jun 16 15:01:01 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 16 Jun 2009 13:01:01 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r73531 - /llvm-gcc-4.2/trunk/gcc/config.gcc In-Reply-To: <200906161853.n5GIrIud002600@zion.cs.uiuc.edu> References: <200906161853.n5GIrIud002600@zion.cs.uiuc.edu> Message-ID: <5DEE8BBD-8A61-415E-9BFA-EB05649714C5@apple.com> Is there a particular reason you used a hyphen in "armv7-a"? None of the other ARM architecture names have hyphens. The LLVM ARM.td file also uses "v7a" (no hyphen) as a SubtargetFeature. I think this should be changed to "armv7a". On Jun 16, 2009, at 11:53 AM, Anton Korobeynikov wrote: > Author: asl > Date: Tue Jun 16 13:53:18 2009 > New Revision: 73531 > > URL: http://llvm.org/viewvc/llvm-project?rev=73531&view=rev > Log: > Add armv7-a to possible list of -with-arch configure options > > Modified: > llvm-gcc-4.2/trunk/gcc/config.gcc > > Modified: llvm-gcc-4.2/trunk/gcc/config.gcc > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config.gcc?rev=73531&r1=73530&r2=73531&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/gcc/config.gcc (original) > +++ llvm-gcc-4.2/trunk/gcc/config.gcc Tue Jun 16 13:53:18 2009 > @@ -2779,11 +2779,14 @@ > fi > done > > + # LLVM LOCAL begin > case "$with_arch" in > "" \ > | armv[23456] | armv2a | armv3m | armv4t | armv5t \ > | armv5te | armv6j |armv6k | armv6z | armv6zk \ > + | armv7-a \ > | iwmmxt | ep9312) > + # LLVM LOCAL end > # OK > ;; > *) > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From anton at korobeynikov.info Tue Jun 16 15:06:05 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 17 Jun 2009 00:06:05 +0400 Subject: [llvm-commits] [llvm-gcc-4.2] r73531 - /llvm-gcc-4.2/trunk/gcc/config.gcc In-Reply-To: <5DEE8BBD-8A61-415E-9BFA-EB05649714C5@apple.com> References: <200906161853.n5GIrIud002600@zion.cs.uiuc.edu> <5DEE8BBD-8A61-415E-9BFA-EB05649714C5@apple.com> Message-ID: Hi, Bob > Is there a particular reason you used a hyphen in "armv7-a"? Mainline gcc uses armv7-a due to unknown (for me) reason. I just wanted to keep compatibility with it. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From aaronngray.lists at googlemail.com Tue Jun 16 15:10:54 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Tue, 16 Jun 2009 21:10:54 +0100 Subject: [llvm-commits] Warn ? Message-ID: Is there an equalilent to 'assert' but to produce a warning in LLVM ? Many thanks in advance, Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090616/5a1184f4/attachment.html From dgregor at apple.com Tue Jun 16 15:12:30 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 16 Jun 2009 20:12:30 -0000 Subject: [llvm-commits] [llvm] r73543 - in /llvm/trunk: ./ autoconf/ include/llvm/ include/llvm/Config/ lib/Target/ARM/ lib/Target/ARM/AsmPrinter/ lib/Target/Alpha/ lib/Target/Alpha/AsmPrinter/ lib/Target/CBackend/ lib/Target/CellSPU/ lib/Target/CellSPU/AsmPrinter/ lib/Target/CppBackend/ lib/Target/IA64/ lib/Target/IA64/AsmPrinter/ lib/Target/MSIL/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/Mips/AsmPrinter/ lib/Target/PIC16/ lib/Target/PowerPC/ lib/Target/PowerPC/AsmPrinter/ lib/Target/Sparc/ lib/Target/Sparc/AsmPrinter/ li... Message-ID: <200906162012.n5GKCV4S006145@zion.cs.uiuc.edu> Author: dgregor Date: Tue Jun 16 15:12:29 2009 New Revision: 73543 URL: http://llvm.org/viewvc/llvm-project?rev=73543&view=rev Log: Introduce new headers whose inclusion forces linking and initialization of all targets (InitializeAllTargets.h) or assembler printers (InitializeAllAsmPrinters.h). This is a step toward the elimination of relinked object files, so that we can build normal archives. Added: llvm/trunk/include/llvm/Config/AsmPrinters.def.in llvm/trunk/include/llvm/Config/Targets.def.in llvm/trunk/include/llvm/InitializeAllAsmPrinters.h llvm/trunk/include/llvm/InitializeAllTargets.h Modified: llvm/trunk/CMakeLists.txt llvm/trunk/Makefile llvm/trunk/autoconf/configure.ac llvm/trunk/configure llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp llvm/trunk/lib/Target/MSIL/MSILWriter.cpp llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp llvm/trunk/lib/Target/PIC16/PIC16TargetMachine.cpp llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.cpp llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp llvm/trunk/tools/llc/llc.cpp Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Tue Jun 16 15:12:29 2009 @@ -81,14 +81,23 @@ set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} ) endif() +set(LLVM_ENUM_TARGETS "") foreach(c ${LLVM_TARGETS_TO_BUILD}) list(FIND LLVM_ALL_TARGETS ${c} idx) if( idx LESS 0 ) message(FATAL_ERROR "The target `${c}' does not exists. It should be one of\n${LLVM_ALL_TARGETS}") + else() + set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${c})\n") endif() endforeach(c) +# Produce llvm/Config/Targets.def +configure_file( + ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.def.in + ${LLVM_BINARY_DIR}/include/llvm/Config/Targets.def + ) + set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm) # The USE_EXPLICIT_DEPENDENCIES variable will be TRUE to indicate that @@ -250,14 +259,23 @@ add_subdirectory(lib/Analysis) add_subdirectory(lib/Analysis/IPA) -foreach(t ${LLVM_TARGETS_TO_BUILD}) + set(LLVM_ENUM_ASM_PRINTERS "") + foreach(t ${LLVM_TARGETS_TO_BUILD}) message(STATUS "Targeting ${t}") add_subdirectory(lib/Target/${t}) if( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt ) - add_subdirectory(lib/Target/${t}/AsmPrinter) - endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt ) + add_subdirectory(lib/Target/${t}/AsmPrinter) + set(LLVM_ENUM_ASM_PRINTERS + "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n") + endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt ) endforeach(t) +# Produce llvm/Config/AsmPrinters.def +configure_file( + ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmPrinters.def.in + ${LLVM_BINARY_DIR}/include/llvm/Config/AsmPrinters.def + ) + add_subdirectory(lib/ExecutionEngine) add_subdirectory(lib/ExecutionEngine/Interpreter) add_subdirectory(lib/ExecutionEngine/JIT) Modified: llvm/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/Makefile (original) +++ llvm/trunk/Makefile Tue Jun 16 15:12:29 2009 @@ -134,6 +134,8 @@ #------------------------------------------------------------------------ FilesToConfig := \ include/llvm/Config/config.h \ + include/llvm/Config/Targets.def \ + include/llvm/Config/AsmPrinters.def \ include/llvm/Support/DataTypes.h \ include/llvm/ADT/iterator.h FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig)) Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Tue Jun 16 15:12:29 2009 @@ -436,6 +436,19 @@ esac AC_SUBST(TARGETS_TO_BUILD,$TARGETS_TO_BUILD) +# Build the LLVM_TARGET and LLVM_ASM_PRINTER macro uses for +# Targets.def and AsmPrinters.def. +LLVM_ENUM_TARGETS="" +LLVM_ENUM_ASM_PRINTERS="" +for target_to_build in $TARGETS_TO_BUILD; do + LLVM_ENUM_TARGETS="LLVM_TARGET($target_to_build) $LLVM_ENUM_TARGETS" + if test -f ${srcdir}/lib/Target/${target_to_build}/AsmPrinter/Makefile ; then + LLVM_ENUM_ASM_PRINTERS="LLVM_ASM_PRINTER($target_to_build) $LLVM_ENUM_ASM_PRINTERS"; + fi +done +AC_SUBST(LLVM_ENUM_TARGETS) +AC_SUBST(LLVM_ENUM_ASM_PRINTERS) + dnl Prevent the CBackend from using printf("%a") for floating point so older dnl C compilers that cannot deal with the 0x0p+0 hex floating point format dnl can still compile the CBE's output @@ -1111,6 +1124,8 @@ dnl contains the same list of files as AC_CONFIG_HEADERS below. This ensures the dnl files can be updated automatically when their *.in sources change. AC_CONFIG_HEADERS([include/llvm/Config/config.h]) +AC_CONFIG_FILES([include/llvm/Config/Targets.def]) +AC_CONFIG_FILES([include/llvm/Config/AsmPrinters.def]) AC_CONFIG_HEADERS([include/llvm/Support/DataTypes.h]) AC_CONFIG_HEADERS([include/llvm/ADT/iterator.h]) Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Tue Jun 16 15:12:29 2009 @@ -841,6 +841,8 @@ ENABLE_THREADS ENABLE_PIC TARGETS_TO_BUILD +LLVM_ENUM_TARGETS +LLVM_ENUM_ASM_PRINTERS ENABLE_CBE_PRINTF_A EXTRA_OPTIONS BINUTILS_INCDIR @@ -4959,6 +4961,19 @@ TARGETS_TO_BUILD=$TARGETS_TO_BUILD +# Build the LLVM_TARGET and LLVM_ASM_PRINTER macro uses for +# Targets.def and AsmPrinters.def. +LLVM_ENUM_TARGETS="" +LLVM_ENUM_ASM_PRINTERS="" +for target_to_build in $TARGETS_TO_BUILD; do + LLVM_ENUM_TARGETS="LLVM_TARGET($target_to_build) $LLVM_ENUM_TARGETS" + if test -f ${srcdir}/lib/Target/${target_to_build}/AsmPrinter/Makefile ; then + LLVM_ENUM_ASM_PRINTERS="LLVM_ASM_PRINTER($target_to_build) $LLVM_ENUM_ASM_PRINTERS"; + fi +done + + + # Check whether --enable-cbe-printf-a was given. if test "${enable_cbe_printf_a+set}" = set; then enableval=$enable_cbe_printf_a; @@ -10594,7 +10609,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 12756 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14456,11 +14471,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14459: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14474: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14463: \$? = $ac_status" >&5 + echo "$as_me:14478: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14724,11 +14739,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14727: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14742: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14731: \$? = $ac_status" >&5 + echo "$as_me:14746: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14828,11 +14843,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14831: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14846: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14835: \$? = $ac_status" >&5 + echo "$as_me:14850: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17280,7 +17295,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:19766: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19755: \$? = $ac_status" >&5 + echo "$as_me:19770: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -19852,11 +19867,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19855: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19870: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19859: \$? = $ac_status" >&5 + echo "$as_me:19874: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21422,11 +21437,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21425: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21440: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21429: \$? = $ac_status" >&5 + echo "$as_me:21444: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21526,11 +21541,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21529: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21544: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21533: \$? = $ac_status" >&5 + echo "$as_me:21548: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -23761,11 +23776,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:23764: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23779: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:23768: \$? = $ac_status" >&5 + echo "$as_me:23783: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24029,11 +24044,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24032: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24047: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24036: \$? = $ac_status" >&5 + echo "$as_me:24051: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24133,11 +24148,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24136: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24151: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24140: \$? = $ac_status" >&5 + echo "$as_me:24155: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -34223,6 +34238,10 @@ ac_config_headers="$ac_config_headers include/llvm/Config/config.h" +ac_config_files="$ac_config_files include/llvm/Config/Targets.def" + +ac_config_files="$ac_config_files include/llvm/Config/AsmPrinters.def" + ac_config_headers="$ac_config_headers include/llvm/Support/DataTypes.h" ac_config_headers="$ac_config_headers include/llvm/ADT/iterator.h" @@ -34849,6 +34868,8 @@ do case $ac_config_target in "include/llvm/Config/config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/Config/config.h" ;; + "include/llvm/Config/Targets.def") CONFIG_FILES="$CONFIG_FILES include/llvm/Config/Targets.def" ;; + "include/llvm/Config/AsmPrinters.def") CONFIG_FILES="$CONFIG_FILES include/llvm/Config/AsmPrinters.def" ;; "include/llvm/Support/DataTypes.h") CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/Support/DataTypes.h" ;; "include/llvm/ADT/iterator.h") CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/ADT/iterator.h" ;; "Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;; @@ -35017,6 +35038,8 @@ ENABLE_THREADS!$ENABLE_THREADS$ac_delim ENABLE_PIC!$ENABLE_PIC$ac_delim TARGETS_TO_BUILD!$TARGETS_TO_BUILD$ac_delim +LLVM_ENUM_TARGETS!$LLVM_ENUM_TARGETS$ac_delim +LLVM_ENUM_ASM_PRINTERS!$LLVM_ENUM_ASM_PRINTERS$ac_delim ENABLE_CBE_PRINTF_A!$ENABLE_CBE_PRINTF_A$ac_delim EXTRA_OPTIONS!$EXTRA_OPTIONS$ac_delim BINUTILS_INCDIR!$BINUTILS_INCDIR$ac_delim @@ -35027,8 +35050,6 @@ ifGNUmake!$ifGNUmake$ac_delim LN_S!$LN_S$ac_delim CMP!$CMP$ac_delim -CP!$CP$ac_delim -DATE!$DATE$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -35070,6 +35091,8 @@ ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +CP!$CP$ac_delim +DATE!$DATE$ac_delim FIND!$FIND$ac_delim MKDIR!$MKDIR$ac_delim MV!$MV$ac_delim @@ -35151,7 +35174,7 @@ LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 79; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 81; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Added: llvm/trunk/include/llvm/Config/AsmPrinters.def.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/AsmPrinters.def.in?rev=73543&view=auto ============================================================================== --- llvm/trunk/include/llvm/Config/AsmPrinters.def.in (added) +++ llvm/trunk/include/llvm/Config/AsmPrinters.def.in Tue Jun 16 15:12:29 2009 @@ -0,0 +1,29 @@ +//===- llvm/Config/AsmPrinters.def - LLVM Assembly Printers -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file enumerates all of the assembly-language printers +// supported by this build of LLVM. Clients of this file should define +// the LLVM_ASM_PRINTER macro to be a function-like macro with a +// single parameter (the name of the target whose assembly can be +// generated); including this file will then enumerate all of the +// targets with assembly printers. +// +// The set of targets supported by LLVM is generated at configuration +// time, at which point this header is generated. Do not modify this +// header directly. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ASM_PRINTER +# error Please define the macro LLVM_ASM_PRINTER(TargetName) +#endif + + at LLVM_ENUM_ASM_PRINTERS@ + +#undef LLVM_ASM_PRINTER Added: llvm/trunk/include/llvm/Config/Targets.def.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/Targets.def.in?rev=73543&view=auto ============================================================================== --- llvm/trunk/include/llvm/Config/Targets.def.in (added) +++ llvm/trunk/include/llvm/Config/Targets.def.in Tue Jun 16 15:12:29 2009 @@ -0,0 +1,28 @@ +//===- llvm/Config/Targets.def - LLVM Target Architectures ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file enumerates all of the target architectures supported by +// this build of LLVM. Clients of this file should define the +// LLVM_TARGET macro to be a function-like macro with a single +// parameter (the name of the target); including this file will then +// enumerate all of the targets. +// +// The set of targets supported by LLVM is generated at configuration +// time, at which point this header is generated. Do not modify this +// header directly. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TARGET +# error Please define the macro LLVM_TARGET(TargetName) +#endif + + at LLVM_ENUM_TARGETS@ + +#undef LLVM_TARGET Added: llvm/trunk/include/llvm/InitializeAllAsmPrinters.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializeAllAsmPrinters.h?rev=73543&view=auto ============================================================================== --- llvm/trunk/include/llvm/InitializeAllAsmPrinters.h (added) +++ llvm/trunk/include/llvm/InitializeAllAsmPrinters.h Tue Jun 16 15:12:29 2009 @@ -0,0 +1,34 @@ +//===- llvm/InitializeAllAsmPrinters.h - Init Asm Printers ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This header initializes all assembler printers for all configured +// LLVM targets, ensuring that they are registered. +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_INITIALIZE_ALL_ASM_PRINTERS_H +#define LLVM_INITIALIZE_ALL_ASM_PRINTERS_H + +namespace llvm { + + // Declare all of the target-initialization functions. +#define LLVM_ASM_PRINTER(TargetName) void Initialize##TargetName##AsmPrinter(); +#include "llvm/Config/AsmPrinters.def" + + namespace { + struct InitializeAllAsmPrinters { + InitializeAllAsmPrinters() { + // Call all of the target-initialization functions. +#define LLVM_ASM_PRINTER(TargetName) llvm::Initialize##TargetName##AsmPrinter(); +#include "llvm/Config/AsmPrinters.def" + } + } DoInitializeAllAsmPrinters; + } +} // end namespace llvm + +#endif // LLVM_INITIALIZE_ALL_ASM_PRINTERS_H Added: llvm/trunk/include/llvm/InitializeAllTargets.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializeAllTargets.h?rev=73543&view=auto ============================================================================== --- llvm/trunk/include/llvm/InitializeAllTargets.h (added) +++ llvm/trunk/include/llvm/InitializeAllTargets.h Tue Jun 16 15:12:29 2009 @@ -0,0 +1,34 @@ +//===- llvm/InitializeAllTargets.h - Initialize All Targets -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This header initializes all configured LLVM targets, ensuring that they +// are registered. +// +//===----------------------------------------------------------------------===// +#ifndef LLVM_INITIALIZE_ALL_TARGETS_H +#define LLVM_INITIALIZE_ALL_TARGETS_H + +namespace llvm { + + // Declare all of the target-initialization functions. +#define LLVM_TARGET(TargetName) void Initialize##TargetName##Target(); +#include "llvm/Config/Targets.def" + + namespace { + struct InitializeAllTargets { + InitializeAllTargets() { + // Call all of the target-initialization functions. +#define LLVM_TARGET(TargetName) llvm::Initialize##TargetName##Target(); +#include "llvm/Config/Targets.def" + } + } DoInitializeAllTargets; + } +} // end namespace llvm + +#endif // LLVM_INITIALIZE_ALL_TARGETS_H Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -42,6 +42,11 @@ static RegisterTarget X("arm", "ARM"); static RegisterTarget Y("thumb", "Thumb"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeARMTarget() { } +} + // No assembler printer by default ARMTargetMachine::AsmPrinterCtorFn ARMTargetMachine::AsmPrinterCtor = 0; Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue Jun 16 15:12:29 2009 @@ -1115,3 +1115,9 @@ } } Registrator; } + +// Force static initialization when called from +// llvm/InitializeAllAsmPrinters.h +namespace llvm { + void InitializeARMAsmPrinter() { } +} Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -31,6 +31,11 @@ // Register the targets static RegisterTarget X("alpha", "Alpha [experimental]"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeAlphaTarget() { } +} + const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const { return new AlphaTargetAsmInfo(*this); } Modified: llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Tue Jun 16 15:12:29 2009 @@ -303,3 +303,9 @@ O << ")"; return false; } + +// Force static initialization when called from +// llvm/InitializeAllAsmPrinters.h +namespace llvm { + void InitializeAlphaAsmPrinter() { } +} Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Tue Jun 16 15:12:29 2009 @@ -59,6 +59,11 @@ // Register the target. static RegisterTarget X("c", "C backend"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeCBackendTarget() { } +} + namespace { /// CBackendNameAllUsedStructsAndMergeFunctions - This pass inserts names for /// any unnamed structure types that are used by the program, and merges Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Tue Jun 16 15:12:29 2009 @@ -621,3 +621,9 @@ bool verbose) { return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), OptLevel, verbose); } + +// Force static initialization when called from +// llvm/InitializeAllAsmPrinters.h +namespace llvm { + void InitializeCellSPUAsmPrinter() { } +} Modified: llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -37,6 +37,11 @@ CELLSPU("cellspu", "STI CBEA Cell SPU [experimental]"); } +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeCellSPUTarget() { } +} + const std::pair * SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const { NumEntries = 1; Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original) +++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Tue Jun 16 15:12:29 2009 @@ -82,6 +82,11 @@ // Register the target. static RegisterTarget X("cpp", "C++ backend"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeCppBackendTarget() { } +} + namespace { typedef std::vector TypeList; typedef std::map TypeMap; Modified: llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp Tue Jun 16 15:12:29 2009 @@ -374,3 +374,9 @@ bool verbose) { return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo(), OptLevel, verbose); } + +// Force static initialization when called from +// llvm/InitializeAllAsmPrinters.h +namespace llvm { + void InitializeIA64AsmPrinter() { } +} Modified: llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -29,6 +29,11 @@ static RegisterTarget X("ia64", "IA-64 (Itanium) [experimental]"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeIA64Target() { } +} + const TargetAsmInfo *IA64TargetMachine::createTargetAsmInfo() const { return new IA64TargetAsmInfo(*this); } Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original) +++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Tue Jun 16 15:12:29 2009 @@ -55,6 +55,11 @@ static RegisterTarget X("msil", "MSIL backend"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeMSILTarget() { } +} + bool MSILModule::runOnModule(Module &M) { ModulePtr = &M; TD = &getAnalysis(); Modified: llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -35,6 +35,11 @@ static RegisterTarget X("msp430", "MSP430 [experimental]"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeMSP430Target() { } +} + MSP430TargetMachine::MSP430TargetMachine(const Module &M, const std::string &FS) : Subtarget(*this, M, FS), Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Tue Jun 16 15:12:29 2009 @@ -578,3 +578,9 @@ return AsmPrinter::doFinalization(M); } + +// Force static initialization when called from +// llvm/InitializeAllAsmPrinters.h +namespace llvm { + void InitializeMipsAsmPrinter() { } +} Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -31,6 +31,11 @@ static RegisterTarget X("mips", "Mips"); static RegisterTarget Y("mipsel", "Mipsel"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeMipsTarget() { } +} + const TargetAsmInfo *MipsTargetMachine:: createTargetAsmInfo() const { Modified: llvm/trunk/lib/Target/PIC16/PIC16TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16TargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16TargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -37,6 +37,11 @@ static RegisterTarget Y("cooper", "PIC16 Cooper [experimental]."); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializePIC16Target() { } +} + // PIC16TargetMachine - Traditional PIC16 Machine. PIC16TargetMachine::PIC16TargetMachine(const Module &M, const std::string &FS, bool Cooper) Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Tue Jun 16 15:12:29 2009 @@ -1202,3 +1202,9 @@ extern "C" int PowerPCAsmPrinterForceLink; int PowerPCAsmPrinterForceLink = 0; + +// Force static initialization when called from +// llvm/InitializeAllAsmPrinters.h +namespace llvm { + void InitializePowerPCAsmPrinter() { } +} Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -35,6 +35,11 @@ static RegisterTarget Y("ppc64", "PowerPC 64"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializePowerPCTarget() { } +} + // No assembler printer by default PPCTargetMachine::AsmPrinterCtorFn PPCTargetMachine::AsmPrinterCtor = 0; Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Tue Jun 16 15:12:29 2009 @@ -353,3 +353,9 @@ return false; } + +// Force static initialization when called from +// llvm/InitializeAllAsmPrinters.h +namespace llvm { + void InitializeSparcAsmPrinter() { } +} Modified: llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -29,6 +29,11 @@ // Register the target. static RegisterTarget X("sparc", "SPARC"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeSparcTarget() { } +} + const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const { // FIXME: Handle Solaris subtarget someday :) return new SparcELFTargetAsmInfo(*this); Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Tue Jun 16 15:12:29 2009 @@ -48,3 +48,9 @@ extern "C" int X86AsmPrinterForceLink; int X86AsmPrinterForceLink = 0; + +// Force static initialization when called from +// llvm/InitializeAllAsmPrinters.h +namespace llvm { + void InitializeX86AsmPrinter() { } +} Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -36,6 +36,11 @@ static RegisterTarget Y("x86-64", "64-bit X86: EM64T and AMD64"); +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeX86Target() { } +} + // No assembler printer by default X86TargetMachine::AsmPrinterCtorFn X86TargetMachine::AsmPrinterCtor = 0; Modified: llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp Tue Jun 16 15:12:29 2009 @@ -31,6 +31,11 @@ RegisterTarget X("xcore", "XCore"); } +// Force static initialization when called from llvm/InitializeAllTargets.h +namespace llvm { + void InitializeXCoreTarget() { } +} + const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const { return new XCoreTargetAsmInfo(*this); } Modified: llvm/trunk/tools/llc/llc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=73543&r1=73542&r2=73543&view=diff ============================================================================== --- llvm/trunk/tools/llc/llc.cpp (original) +++ llvm/trunk/tools/llc/llc.cpp Tue Jun 16 15:12:29 2009 @@ -38,6 +38,8 @@ #include "llvm/System/Signals.h" #include "llvm/Config/config.h" #include "llvm/LinkAllVMCore.h" +#include "llvm/InitializeAllTargets.h" +#include "llvm/InitializeAllAsmPrinters.h" #include #include #include From anton at korobeynikov.info Tue Jun 16 15:17:39 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 17 Jun 2009 00:17:39 +0400 Subject: [llvm-commits] Warn ? In-Reply-To: References: Message-ID: > Is there an equalilent to 'assert' but to produce a warning in LLVM ? printf? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From resistor at mac.com Tue Jun 16 15:19:28 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 20:19:28 -0000 Subject: [llvm-commits] [llvm] r73545 - in /llvm/trunk: include/llvm/System/RWMutex.h lib/System/RWMutex.cpp lib/System/Unix/RWMutex.inc lib/System/Win32/Mutex.inc lib/System/Win32/RWMutex.inc Message-ID: <200906162019.n5GKJScH006431@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 15:19:28 2009 New Revision: 73545 URL: http://llvm.org/viewvc/llvm-project?rev=73545&view=rev Log: Add a portable wrapper for reader-writer locks. Added: llvm/trunk/include/llvm/System/RWMutex.h llvm/trunk/lib/System/RWMutex.cpp llvm/trunk/lib/System/Unix/RWMutex.inc llvm/trunk/lib/System/Win32/RWMutex.inc Modified: llvm/trunk/lib/System/Win32/Mutex.inc Added: llvm/trunk/include/llvm/System/RWMutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/RWMutex.h?rev=73545&view=auto ============================================================================== --- llvm/trunk/include/llvm/System/RWMutex.h (added) +++ llvm/trunk/include/llvm/System/RWMutex.h Tue Jun 16 15:19:28 2009 @@ -0,0 +1,84 @@ +//===- RWMutex.h - Reader/Writer Mutual Exclusion Lock ----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the llvm::sys::RWMutex class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SYSTEM_MUTEX_H +#define LLVM_SYSTEM_MUTEX_H + +namespace llvm +{ + namespace sys + { + /// @brief Platform agnostic Mutex class. + class RWMutex + { + /// @name Constructors + /// @{ + public: + + /// Initializes the lock but doesn't acquire it. + /// @brief Default Constructor. + explicit RWMutex(); + + /// Releases and removes the lock + /// @brief Destructor + ~RWMutex(); + + /// @} + /// @name Methods + /// @{ + public: + + /// Attempts to unconditionally acquire the lock in reader mode. If the + /// lock is held by a writer, this method will wait until it can acquire + /// the lock. + /// @returns false if any kind of error occurs, true otherwise. + /// @brief Unconditionally acquire the lock in reader mode. + bool reader_acquire(); + + /// Attempts to release the lock in reader mode. + /// @returns false if any kind of error occurs, true otherwise. + /// @brief Unconditionally release the lock in reader mode. + bool reader_release(); + + /// Attempts to unconditionally acquire the lock in reader mode. If the + /// lock is held by any readers, this method will wait until it can + /// acquire the lock. + /// @returns false if any kind of error occurs, true otherwise. + /// @brief Unconditionally acquire the lock in writer mode. + bool writer_acquire(); + + /// Attempts to release the lock in writer mode. + /// @returns false if any kind of error occurs, true otherwise. + /// @brief Unconditionally release the lock in write mode. + bool writer_release(); + + //@} + /// @name Platform Dependent Data + /// @{ + private: +#ifdef ENABLE_THREADS + void* data_; ///< We don't know what the data will be +#endif + + /// @} + /// @name Do Not Implement + /// @{ + private: + RWMutex(const RWMutex & original); + void operator=(const RWMutex &); + /// @} + }; + } +} + +#endif Added: llvm/trunk/lib/System/RWMutex.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/RWMutex.cpp?rev=73545&view=auto ============================================================================== --- llvm/trunk/lib/System/RWMutex.cpp (added) +++ llvm/trunk/lib/System/RWMutex.cpp Tue Jun 16 15:19:28 2009 @@ -0,0 +1,169 @@ +//===- RWMutex.cpp - Reader/Writer Mutual Exclusion Lock --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the llvm::sys::RWMutex class. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Config/config.h" +#include "llvm/System/RWMutex.h" + +//===----------------------------------------------------------------------===// +//=== WARNING: Implementation here must contain only TRULY operating system +//=== independent code. +//===----------------------------------------------------------------------===// + +#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0 +// Define all methods as no-ops if threading is explicitly disabled +namespace llvm { +using namespace sys; +RWMutex::RWMutex( bool recursive) { } +RWMutex::~RWMutex() { } +bool RWMutex::reader_acquire() { return true; } +bool RWMutex::reader_release() { return true; } +bool RWMutex::writer_acquire() { return true; } +bool RWMutex::writer_release() { return true; } +} +#else + +#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_RWLOCK_INIT) + +#include +#include +#include + +namespace llvm { +using namespace sys; + + +// This variable is useful for situations where the pthread library has been +// compiled with weak linkage for its interface symbols. This allows the +// threading support to be turned off by simply not linking against -lpthread. +// In that situation, the value of pthread_mutex_init will be 0 and +// consequently pthread_enabled will be false. In such situations, all the +// pthread operations become no-ops and the functions all return false. If +// pthread_rwlock_init does have an address, then rwlock support is enabled. +// Note: all LLVM tools will link against -lpthread if its available since it +// is configured into the LIBS variable. +// Note: this line of code generates a warning if pthread_rwlock_init is not +// declared with weak linkage. It's safe to ignore the warning. +static const bool pthread_enabled = true; + +// Construct a RWMutex using pthread calls +RWMutex::RWMutex() + : data_(0) +{ + if (pthread_enabled) + { + // Declare the pthread_rwlock data structures + pthread_rwlock_t* rwlock = + static_cast(malloc(sizeof(pthread_rwlock_t))); + pthread_rwlockattr_t attr; + + // Initialize the rwlock attributes + int errorcode = pthread_rwlockattr_init(&attr); + assert(errorcode == 0); + +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) + // Make it a process local rwlock + errorcode = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE); +#endif + + // Initialize the rwlock + errorcode = pthread_rwlock_init(rwlock, &attr); + assert(errorcode == 0); + + // Destroy the attributes + errorcode = pthread_rwlockattr_destroy(&attr); + assert(errorcode == 0); + + // Assign the data member + data_ = rwlock; + } +} + +// Destruct a RWMutex +RWMutex::~RWMutex() +{ + if (pthread_enabled) + { + pthread_rwlock_t* rwlock = static_cast(data_); + assert(rwlock != 0); + pthread_rwlock_destroy(rwlock); + free(rwlock); + } +} + +bool +RWMutex::reader_acquire() +{ + if (pthread_enabled) + { + pthread_rwlock_t* rwlock = static_cast(data_); + assert(rwlock != 0); + + int errorcode = pthread_rwlock_rdlock(rwlock); + return errorcode == 0; + } + return false; +} + +bool +RWMutex::reader_release() +{ + if (pthread_enabled) + { + pthread_rwlock_t* rwlock = static_cast(data_); + assert(rwlock != 0); + + int errorcode = pthread_rwlock_unlock(rwlock); + return errorcode == 0; + } + return false; +} + +bool +RWMutex::writer_acquire() +{ + if (pthread_enabled) + { + pthread_rwlock_t* rwlock = static_cast(data_); + assert(rwlock != 0); + + int errorcode = pthread_rwlock_wrlock(rwlock); + return errorcode == 0; + } + return false; +} + +bool +RWMutex::writer_release() +{ + if (pthread_enabled) + { + pthread_rwlock_t* rwlock = static_cast(data_); + assert(rwlock != 0); + + int errorcode = pthread_rwlock_unlock(rwlock); + return errorcode == 0; + } + return false; +} + +} + +#elif defined(LLVM_ON_UNIX) +#include "Unix/RWMutex.inc" +#elif defined( LLVM_ON_WIN32) +#include "Win32/RWMutex.inc" +#else +#warning Neither LLVM_ON_UNIX nor LLVM_ON_WIN32 was set in System/Mutex.cpp +#endif +#endif + Added: llvm/trunk/lib/System/Unix/RWMutex.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/RWMutex.inc?rev=73545&view=auto ============================================================================== --- llvm/trunk/lib/System/Unix/RWMutex.inc (added) +++ llvm/trunk/lib/System/Unix/RWMutex.inc Tue Jun 16 15:19:28 2009 @@ -0,0 +1,43 @@ +//= llvm/System/Unix/RWMutex.inc - Unix Reader/Writer Mutual Exclusion Lock =// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the Unix specific (non-pthread) RWMutex class. +// +//===----------------------------------------------------------------------===// + +//===----------------------------------------------------------------------===// +//=== WARNING: Implementation here must contain only generic UNIX code that +//=== is guaranteed to work on *all* UNIX variants. +//===----------------------------------------------------------------------===// + +namespace llvm { + +using namespace sys; + +RWMutex::RWMutex() { } + +RWMutex::~RWMutex() { } + +bool RWMutex::reader_acquire() { + return true; +} + +bool RWMutex::reader_release() { + return true; +} + +bool RWMutex::writer_acquire() { + return true; +} + +bool RWMutex::writer_release() { + return true; +} + +} Modified: llvm/trunk/lib/System/Win32/Mutex.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Mutex.inc?rev=73545&r1=73544&r2=73545&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/Mutex.inc (original) +++ llvm/trunk/lib/System/Win32/Mutex.inc Tue Jun 16 15:19:28 2009 @@ -22,7 +22,7 @@ namespace llvm { using namespace sys; -Mutex::Mutex(bool /*recursive*/) +Mutex::Mutex() { data_ = new CRITICAL_SECTION; InitializeCriticalSection((LPCRITICAL_SECTION)data_); Added: llvm/trunk/lib/System/Win32/RWMutex.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/RWMutex.inc?rev=73545&view=auto ============================================================================== --- llvm/trunk/lib/System/Win32/RWMutex.inc (added) +++ llvm/trunk/lib/System/Win32/RWMutex.inc Tue Jun 16 15:19:28 2009 @@ -0,0 +1,55 @@ +//= llvm/System/Win32/Mutex.inc - Win32 Reader/Writer Mutual Exclusion Lock =// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the Win32 specific (non-pthread) RWMutex class. +// +//===----------------------------------------------------------------------===// + +//===----------------------------------------------------------------------===// +//=== WARNING: Implementation here must contain only generic Win32 code that +//=== is guaranteed to work on *all* Win32 variants. +//===----------------------------------------------------------------------===// + +#include "Win32.h" + +namespace llvm { +using namespace sys; + +RWMutex::RWMutex() { + data_ = new PSRWLOCK; + InitializeSRWLock((PSRWLOCK*)data_); +} + +RWMutex::~RWMutex() { + delete (PSRWLOCK*)data_; + data_ = 0; +} + +bool RWMutex::reader_acquire() { + AcquireSRWLockShared((PSRWLOCK*)data_); + return true; +} + +bool RWMutex::reader_release() { + ReleaseSRWLockShared((PSRWLOCK*)data_); + return true; +} + +bool RWMutex::writer_acquire() { + AcquireSRWLockExclusive((PSRWLOCK*)data_); + return true; +} + +bool RWMutex::writer_release() { + ReleaseSRWLockExclusive((PSRWLOCK*)data_); + return true; +} + + +} From bob.wilson at apple.com Tue Jun 16 15:19:49 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 16 Jun 2009 13:19:49 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r73531 - /llvm-gcc-4.2/trunk/gcc/config.gcc In-Reply-To: References: <200906161853.n5GIrIud002600@zion.cs.uiuc.edu> <5DEE8BBD-8A61-415E-9BFA-EB05649714C5@apple.com> Message-ID: <605B763A-B9D7-4E78-B731-335D3DAB63B2@apple.com> On Jun 16, 2009, at 1:06 PM, Anton Korobeynikov wrote: > Hi, Bob > >> Is there a particular reason you used a hyphen in "armv7-a"? > Mainline gcc uses armv7-a due to unknown (for me) reason. I just > wanted to keep compatibility with it. OK. I agree that we should try to be compatible. From resistor at mac.com Tue Jun 16 15:23:05 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 20:23:05 -0000 Subject: [llvm-commits] [llvm] r73546 - in /llvm/trunk: include/llvm/Support/Threading.h lib/System/RWMutex.cpp Message-ID: <200906162023.n5GKN5sK006590@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 15:23:05 2009 New Revision: 73546 URL: http://llvm.org/viewvc/llvm-project?rev=73546&view=rev Log: Fix/cleanup trailing newlines. Modified: llvm/trunk/include/llvm/Support/Threading.h llvm/trunk/lib/System/RWMutex.cpp Modified: llvm/trunk/include/llvm/Support/Threading.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Threading.h?rev=73546&r1=73545&r2=73546&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Threading.h (original) +++ llvm/trunk/include/llvm/Support/Threading.h Tue Jun 16 15:23:05 2009 @@ -42,4 +42,4 @@ void llvm_release_global_lock(); } -#endif \ No newline at end of file +#endif Modified: llvm/trunk/lib/System/RWMutex.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/RWMutex.cpp?rev=73546&r1=73545&r2=73546&view=diff ============================================================================== --- llvm/trunk/lib/System/RWMutex.cpp (original) +++ llvm/trunk/lib/System/RWMutex.cpp Tue Jun 16 15:23:05 2009 @@ -166,4 +166,3 @@ #warning Neither LLVM_ON_UNIX nor LLVM_ON_WIN32 was set in System/Mutex.cpp #endif #endif - From asl at math.spbu.ru Tue Jun 16 15:25:26 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 16 Jun 2009 20:25:26 -0000 Subject: [llvm-commits] [llvm] r73547 - /llvm/trunk/test/CodeGen/ARM/vargs2.ll Message-ID: <200906162025.n5GKPQWF006674@zion.cs.uiuc.edu> Author: asl Date: Tue Jun 16 15:25:25 2009 New Revision: 73547 URL: http://llvm.org/viewvc/llvm-project?rev=73547&view=rev Log: Make the test target-neutral Modified: llvm/trunk/test/CodeGen/ARM/vargs2.ll Modified: llvm/trunk/test/CodeGen/ARM/vargs2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vargs2.ll?rev=73547&r1=73546&r2=73547&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vargs2.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vargs2.ll Tue Jun 16 15:25:25 2009 @@ -1,6 +1,6 @@ ; RUN: llvm-as < %s | llc -march=thumb -; RUN: llvm-as < %s | llc -march=thumb | \ -; RUN: grep pop | count 1 +; RUN: llvm-as < %s | llc -mtriple=arm-linux -march=thumb | grep pop | count 1 +; RUN: llvm-as < %s | llc -mtriple=arm-darwin -march=thumb | grep pop | count 2 @str = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1] From resistor at mac.com Tue Jun 16 15:26:06 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 20:26:06 -0000 Subject: [llvm-commits] [llvm] r73548 - /llvm/trunk/include/llvm/System/RWMutex.h Message-ID: <200906162026.n5GKQ6Cu006700@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 15:26:04 2009 New Revision: 73548 URL: http://llvm.org/viewvc/llvm-project?rev=73548&view=rev Log: Fix #include guards. Modified: llvm/trunk/include/llvm/System/RWMutex.h Modified: llvm/trunk/include/llvm/System/RWMutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/RWMutex.h?rev=73548&r1=73547&r2=73548&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/RWMutex.h (original) +++ llvm/trunk/include/llvm/System/RWMutex.h Tue Jun 16 15:26:04 2009 @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SYSTEM_MUTEX_H -#define LLVM_SYSTEM_MUTEX_H +#ifndef LLVM_SYSTEM_RWMUTEX_H +#define LLVM_SYSTEM_RWMUTEX_H namespace llvm { From resistor at mac.com Tue Jun 16 15:49:20 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 20:49:20 -0000 Subject: [llvm-commits] [llvm] r73550 - /llvm/trunk/lib/System/Win32/RWMutex.inc Message-ID: <200906162049.n5GKnKHF007604@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 15:49:20 2009 New Revision: 73550 URL: http://llvm.org/viewvc/llvm-project?rev=73550&view=rev Log: Remove the Win32 implementation, since it doesn't compile pre-Vista. Modified: llvm/trunk/lib/System/Win32/RWMutex.inc Modified: llvm/trunk/lib/System/Win32/RWMutex.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/RWMutex.inc?rev=73550&r1=73549&r2=73550&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/RWMutex.inc (original) +++ llvm/trunk/lib/System/Win32/RWMutex.inc Tue Jun 16 15:49:20 2009 @@ -18,36 +18,31 @@ #include "Win32.h" +// FIXME: THIS IS NOT THREAD-SAFE!! +// Windows does not have reader-writer locks pre-Vista. If you want to have +// thread-safe LLVM on Windows, for now at least, you need to use a pthreads +// replacement library. + namespace llvm { using namespace sys; -RWMutex::RWMutex() { - data_ = new PSRWLOCK; - InitializeSRWLock((PSRWLOCK*)data_); -} +RWMutex::RWMutex() { } -RWMutex::~RWMutex() { - delete (PSRWLOCK*)data_; - data_ = 0; -} +RWMutex::~RWMutex() { } bool RWMutex::reader_acquire() { - AcquireSRWLockShared((PSRWLOCK*)data_); return true; } bool RWMutex::reader_release() { - ReleaseSRWLockShared((PSRWLOCK*)data_); return true; } bool RWMutex::writer_acquire() { - AcquireSRWLockExclusive((PSRWLOCK*)data_); return true; } bool RWMutex::writer_release() { - ReleaseSRWLockExclusive((PSRWLOCK*)data_); return true; } From fvbommel at wxs.nl Tue Jun 16 15:49:41 2009 From: fvbommel at wxs.nl (Frits van Bommel) Date: Tue, 16 Jun 2009 22:49:41 +0200 Subject: [llvm-commits] [PATCH] Tail recursion elimination and memory loads. Message-ID: <4A380565.5050203@wxs.nl> When tail recursion elimination (opt -tailcallelim) sees other instructions between the recursive call and the return instruction, it tries to figure out if it's safe to move them above the call (putting the call in tail position). However, it refuses to do that for load instructions after the call. The attached patch checks for some conditions in which it is safe to do this for loads as well. There are two basic cases: 1) The call has no side-effects, in which case it's always safe since the load would happen anyway and it shouldn't matter if it's done a bit sooner. 2) The load is non-volatile, the call does not write to memory, and the pointer isSafeToLoadUnconditionally() at that point in the code. In this case, the load has no side-effects (and won't trap) and the memory it loads from won't contain different data after the call, making it safe to raise the load above the call. If the load and call in question satisfy either of these conditions tail recursion elimination will be allowed (or at least, it won't be blocked by that load). See also: http://llvm.org/PR4323 -------------- next part -------------- A non-text attachment was scrubbed... Name: tailcallelim-reorder-load.patch Type: text/x-patch Size: 7871 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090616/f84d7c10/attachment.bin From eocallaghan at auroraux.org Tue Jun 16 15:50:19 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Tue, 16 Jun 2009 21:50:19 +0100 Subject: [llvm-commits] [PATCH] Missing new line at the end of a few files. Message-ID: <521640720906161350q44e4265fuae3ca460deb7df4d@mail.gmail.com> Good day, I believe a few people have different platforms and editors of choice so these little grammar errors creep in: http://junk.auroraux.org/Makefile.rules.udiff http://junk.auroraux.org/Threading.h.udiff http://junk.auroraux.org/Threading.cpp.udiff At revision 73549. The change in the Makefile.rules insures that missing new line feeds should be an error since the spec says so. ISO/IEC 14882:1998(E) ?2.1:2 on page 9 (logical page) (physical page 35) I highly appreciate our warning free builds and hope this maintains it by forcing people with such editors to keep to the spec. Its a fine example of our code base cleanness and correctness. Thanks for your time, Edward. -- -- Edward O'Callaghan http://www.auroraux.org/ eocallaghan at auroraux dot org From resistor at mac.com Tue Jun 16 15:53:09 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 20:53:09 -0000 Subject: [llvm-commits] [llvm] r73551 - /llvm/trunk/lib/Support/Threading.cpp Message-ID: <200906162053.n5GKrAhr007898@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 15:53:09 2009 New Revision: 73551 URL: http://llvm.org/viewvc/llvm-project?rev=73551&view=rev Log: Add newline at end of file. Modified: llvm/trunk/lib/Support/Threading.cpp Modified: llvm/trunk/lib/Support/Threading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Threading.cpp?rev=73551&r1=73550&r2=73551&view=diff ============================================================================== --- llvm/trunk/lib/Support/Threading.cpp (original) +++ llvm/trunk/lib/Support/Threading.cpp Tue Jun 16 15:53:09 2009 @@ -60,4 +60,4 @@ void llvm::llvm_release_global_lock() { if (multithreaded_mode) global_lock->release(); -} \ No newline at end of file +} From resistor at mac.com Tue Jun 16 15:57:51 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 20:57:51 -0000 Subject: [llvm-commits] [llvm] r73552 - /llvm/trunk/lib/System/Win32/Mutex.inc Message-ID: <200906162057.n5GKvpAp008044@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 15:57:51 2009 New Revision: 73552 URL: http://llvm.org/viewvc/llvm-project?rev=73552&view=rev Log: Accidentally broke this file. Modified: llvm/trunk/lib/System/Win32/Mutex.inc Modified: llvm/trunk/lib/System/Win32/Mutex.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Mutex.inc?rev=73552&r1=73551&r2=73552&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/Mutex.inc (original) +++ llvm/trunk/lib/System/Win32/Mutex.inc Tue Jun 16 15:57:51 2009 @@ -22,7 +22,7 @@ namespace llvm { using namespace sys; -Mutex::Mutex() +Mutex::Mutex(bool /*recursive*/) { data_ = new CRITICAL_SECTION; InitializeCriticalSection((LPCRITICAL_SECTION)data_); From me22.ca at gmail.com Tue Jun 16 15:58:44 2009 From: me22.ca at gmail.com (me22) Date: Tue, 16 Jun 2009 13:58:44 -0700 Subject: [llvm-commits] CVS: llvm-www/OpenProjects.html In-Reply-To: <38a0d8450906160435i40749ec2w9cc258e9448479d1@mail.gmail.com> References: <200906160632.n5G6Wqu2027226@zion.cs.uiuc.edu> <38a0d8450906160435i40749ec2w9cc258e9448479d1@mail.gmail.com> Message-ID: 2009/6/16 Rafael Espindola > > > + ?
  • Value > > + ? ? ?assertions (also PR810).
  • > > ? > > The example > > ? int test(char *f) { > ? ? if (*f) > ? ? ? __builtin_unreachable (); > ? ? return f ? 1 : 0; > ? } > > > should probably be > > ? int test(char *f) { > ? ? if (*f) > ? ? ? __builtin_unreachable (); > ? ? return *f ? 0 : 1; > ? } > > for it to be reduced to "return 1". > Well arguably just this is enough to be reduced to "return 1": int test(char *f) { *f; return f ? 1 : 0; } But I agree, it probably should be made more obvious. Why not just this, though?: int test(char c) { if (c) __builtin_unreachable (); return !c; } ~ Scott From eocallaghan at auroraux.org Tue Jun 16 16:09:17 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Tue, 16 Jun 2009 22:09:17 +0100 Subject: [llvm-commits] [PATCH] Missing new line at the end of a few files. In-Reply-To: <521640720906161350q44e4265fuae3ca460deb7df4d@mail.gmail.com> References: <521640720906161350q44e4265fuae3ca460deb7df4d@mail.gmail.com> Message-ID: <521640720906161409y4ad914ecwc9e94708e4a057bd@mail.gmail.com> Stupid me only just remembered the `svn diff` command: http://junk.auroraux.org/llvm.M.T.T.patch This should make peoples lives easier. :) Silly me :p Cheers, Edward. 2009/6/16 Edward O'Callaghan : > Good day, > > I believe a few people have different platforms and editors of choice > so these little grammar errors creep in: > > http://junk.auroraux.org/Makefile.rules.udiff > http://junk.auroraux.org/Threading.h.udiff > http://junk.auroraux.org/Threading.cpp.udiff > > At revision 73549. > > The change in the Makefile.rules insures that missing new line feeds > should be an error since the spec says so. > ISO/IEC 14882:1998(E) ?2.1:2 > on page 9 > (logical page) > (physical page 35) > > I highly appreciate our warning free builds and hope this maintains it > by forcing people with such editors to keep to the spec. Its a fine > example of our code base cleanness and correctness. > > Thanks for your time, > > Edward. > > -- > -- > Edward O'Callaghan > http://www.auroraux.org/ > eocallaghan at auroraux dot org > -- -- Edward O'Callaghan http://www.auroraux.org/ eocallaghan at auroraux dot org From sabre at nondot.org Tue Jun 16 16:16:30 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 21:16:30 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73553 - in /llvm-gcc-4.2/trunk/gcc: config/alpha/alpha.h config/arm/arm.h config/i386/i386.h config/ia64/ia64.h config/mips/llvm-mips-target.h config/rs6000/rs6000.h llvm-backend.cpp Message-ID: <200906162116.n5GLGVow008756@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 16:16:30 2009 New Revision: 73553 URL: http://llvm.org/viewvc/llvm-project?rev=73553&view=rev Log: Initialize the target and asm printer for the currently configured code generator before using it. This is a step towards switching from "targets in .o files" to "targets in .a files". Modified: llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h llvm-gcc-4.2/trunk/gcc/config/arm/arm.h llvm-gcc-4.2/trunk/gcc/config/i386/i386.h llvm-gcc-4.2/trunk/gcc/config/ia64/ia64.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/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h?rev=73553&r1=73552&r2=73553&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/alpha/alpha.h Tue Jun 16 16:16:30 2009 @@ -1600,6 +1600,12 @@ */ #define LLVM_TARGET_INTRINSIC_PREFIX "alpha" +/* LLVM_TARGET_NAME - This specifies the name of the target, which correlates to + * the llvm::InitializeXXXTarget() function. + */ +#define LLVM_TARGET_NAME Alpha + + /* LLVM_TARGET_INTRINSIC_LOWER - To handle builtins, we want to expand the * invocation into normal LLVM code. If the target can handle the builtin, this * macro should call the target TreeToLLVM::TargetIntrinsicLower method and Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=73553&r1=73552&r2=73553&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Tue Jun 16 16:16:30 2009 @@ -2962,6 +2962,12 @@ #ifdef ENABLE_LLVM #define LLVM_TARGET_INTRINSIC_PREFIX "arm" +/* LLVM_TARGET_NAME - This specifies the name of the target, which correlates to + * the llvm::InitializeXXXTarget() function. + */ +#define LLVM_TARGET_NAME ARM + + /* Turn -march=xx into a CPU type. */ #define LLVM_SET_SUBTARGET_FEATURES(F) \ Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.h?rev=73553&r1=73552&r2=73553&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/i386.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.h Tue Jun 16 16:16:30 2009 @@ -3863,11 +3863,16 @@ }; #ifdef ENABLE_LLVM + /* LLVM_TARGET_INTRINSIC_PREFIX - Specify what prefix this target uses for its * intrinsics. */ #define LLVM_TARGET_INTRINSIC_PREFIX "x86" +/* LLVM_TARGET_NAME - This specifies the name of the target, which correlates to + * the llvm::InitializeXXXTarget() function. + */ +#define LLVM_TARGET_NAME X86 /* Turn -march=xx into a CPU type. */ Modified: llvm-gcc-4.2/trunk/gcc/config/ia64/ia64.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/ia64/ia64.h?rev=73553&r1=73552&r2=73553&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/ia64/ia64.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/ia64/ia64.h Tue Jun 16 16:16:30 2009 @@ -2009,6 +2009,12 @@ /* LLVM LOCAL begin */ #define TARGET_UNWIND_TABLES_DEFAULT true + +/* LLVM_TARGET_NAME - This specifies the name of the target, which correlates to + * the llvm::InitializeXXXTarget() function. + */ +#define LLVM_TARGET_NAME IA64 + /* LLVM LOCAL end */ #define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 15 : INVALID_REGNUM) 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=73553&r1=73552&r2=73553&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 Tue Jun 16 16:16:30 2009 @@ -27,6 +27,11 @@ #define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ llvm_mips_should_pass_aggregate_in_memory(X, TY) +/* LLVM_TARGET_NAME - This specifies the name of the target, which correlates to + * the llvm::InitializeXXXTarget() function. + */ +#define LLVM_TARGET_NAME Mips + #endif /* LLVM_ABI_H */ /* LLVM LOCAL end (ENTIRE FILE!) */ 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=73553&r1=73552&r2=73553&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h Tue Jun 16 16:16:30 2009 @@ -3452,6 +3452,11 @@ #ifdef ENABLE_LLVM #define LLVM_TARGET_INTRINSIC_PREFIX "ppc" +/* LLVM_TARGET_NAME - This specifies the name of the target, which correlates to + * the llvm::InitializeXXXTarget() function. + */ +#define LLVM_TARGET_NAME PowerPC + /* Turn -march=xx into a CPU type. */ #define LLVM_SET_SUBTARGET_FEATURES(F) \ 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=73553&r1=73552&r2=73553&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Tue Jun 16 16:16:30 2009 @@ -51,6 +51,7 @@ #include "llvm/Support/Streams.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Program.h" + #include #undef VISIBILITY_HIDDEN extern "C" { @@ -326,7 +327,28 @@ } } +#ifndef LLVM_TARGET_NAME +#error LLVM_TARGET_NAME macro not specified by GCC backend +#endif + +namespace llvm { +#define Declare2(TARG, MOD) void Initialize ## TARG ## MOD() +#define Declare(T, M) Declare2(T, M) + Declare(LLVM_TARGET_NAME, Target); + Declare(LLVM_TARGET_NAME, AsmPrinter); +#undef Declare +#undef Declare2 +} + void llvm_initialize_backend(void) { + // Initialize the LLVM backend. +#define DoInit2(TARG, MOD) llvm::Initialize ## TARG ## MOD() +#define DoInit(T, M) DoInit2(T, M) + DoInit(LLVM_TARGET_NAME, Target); + DoInit(LLVM_TARGET_NAME, AsmPrinter); +#undef DoInit +#undef DoInit2 + // Initialize LLVM options. std::vector Args; Args.push_back(progname); // program name From sabre at nondot.org Tue Jun 16 16:33:20 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 21:33:20 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73554 - /llvm-gcc-4.2/trunk/gcc/Makefile.in Message-ID: <200906162133.n5GLXKkS009422@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 16:33:20 2009 New Revision: 73554 URL: http://llvm.org/viewvc/llvm-project?rev=73554&view=rev Log: When building the libllvmgcc*.dylib for an apple-style build, make sure to use -u to pull in the x86/ppc/arm targets and asmprinters. Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/Makefile.in?rev=73554&r1=73553&r2=73554&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/Makefile.in (original) +++ llvm-gcc-4.2/trunk/gcc/Makefile.in Tue Jun 16 16:33:20 2009 @@ -1170,6 +1170,7 @@ # See below for more details. ifdef BUILD_LLVM_INTO_A_DYLIB LLVMTARGETOBJ := $(sort $(LLVMTARGETOBJ) x86 powerpc arm) +LLVMTARGETNAME := $(sort X86 PowerPC ARM) endif # We use llvm-config to determine the libraries that we need to link in our @@ -1232,7 +1233,9 @@ $(CXX) $(DYLIB_COMPILE_FLAGS) $(INCLUDES) -o $@ \ $< $(LLVMLIBFILES) -dynamiclib -single_module \ -compatibility_version 1.0.0 -current_version 1.0.0 \ - -install_name @executable_path/$@ + -install_name @executable_path/$@ \ + $(patsubst %,-u __ZN4llvm19Initialize%TargetEv,$(LLVMTARGETNAME)) \ + $(patsubst %,-u __ZN4llvm19Initialize%AsmPrinterEv,$(LLVMTARGETNAME)) \ LLVMBACKENDFILES := libllvmgcc$(LLVM_STAGE).dylib From aaronngray.lists at googlemail.com Tue Jun 16 16:52:28 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Tue, 16 Jun 2009 22:52:28 +0100 Subject: [llvm-commits] Warn ? References: Message-ID: <95DCC6E166DD41C1B96BF9D9BCA19BBA@HPLAPTOP> >> Is there an equalilent to 'assert' but to produce a warning in LLVM ? > printf? mmm, wrong I got the mailing list, sorry. Aaron From gordonhenriksen at me.com Tue Jun 16 17:05:10 2009 From: gordonhenriksen at me.com (Gordon Henriksen) Date: Tue, 16 Jun 2009 18:05:10 -0400 Subject: [llvm-commits] [llvm] r71785 - /llvm/trunk/lib/CodeGen/MachineFunction.cpp In-Reply-To: References: <200905141917.n4EJHmn9007286@zion.cs.uiuc.edu> Message-ID: On May 14, 2009, at 16:37, Chris Lattner wrote: > > On May 14, 2009, at 12:17 PM, Owen Anderson wrote: > >> Author: resistor >> Date: Thu May 14 14:17:24 2009 >> New Revision: 71785 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=71785&view=rev >> Log: >> Down with static variables! > > Could we make MachineFunction an analysis pass instead of an > annotation on Function? I tried this once and it doesn't work well?passes tend to invalidate the MachineFunction analysis. ? Gordon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090616/efb6dafb/attachment.html From dalej at apple.com Tue Jun 16 17:17:21 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 16 Jun 2009 22:17:21 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73564 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <200906162217.n5GMHLXd011055@zion.cs.uiuc.edu> Author: johannes Date: Tue Jun 16 17:17:20 2009 New Revision: 73564 URL: http://llvm.org/viewvc/llvm-project?rev=73564&view=rev Log: Don't emit debug info for TEMPLATE_DECL members. This is pointless, and can cause a crash. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=73564&r1=73563&r2=73564&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue Jun 16 17:17:20 2009 @@ -664,6 +664,8 @@ if (DECL_ABSTRACT_ORIGIN (Member)) continue; if (DECL_ARTIFICIAL (Member)) continue; + // In C++, TEMPLATE_DECLs are marked Ignored, and should be. + if (DECL_P (Member) && DECL_IGNORED_P (Member)) continue; // Get the location of the member. expanded_location MemLoc = GetNodeLocation(Member, false); From dalej at apple.com Tue Jun 16 17:18:33 2009 From: dalej at apple.com (Dale Johannesen) Date: Tue, 16 Jun 2009 22:18:33 -0000 Subject: [llvm-commits] [llvm] r73565 - /llvm/trunk/test/FrontendC++/2009-06-16-DebugInfoCrash.cpp Message-ID: <200906162218.n5GMIXQW011099@zion.cs.uiuc.edu> Author: johannes Date: Tue Jun 16 17:18:33 2009 New Revision: 73565 URL: http://llvm.org/viewvc/llvm-project?rev=73565&view=rev Log: Test for llvm-gcc patch 73564. Added: llvm/trunk/test/FrontendC++/2009-06-16-DebugInfoCrash.cpp Added: llvm/trunk/test/FrontendC++/2009-06-16-DebugInfoCrash.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2009-06-16-DebugInfoCrash.cpp?rev=73565&view=auto ============================================================================== --- llvm/trunk/test/FrontendC++/2009-06-16-DebugInfoCrash.cpp (added) +++ llvm/trunk/test/FrontendC++/2009-06-16-DebugInfoCrash.cpp Tue Jun 16 17:18:33 2009 @@ -0,0 +1,10 @@ +// RUN: %llvmgxx -c -emit-llvm %s -o /dev/null -g +// This crashes if we try to emit debug info for TEMPLATE_DECL members. +template class K2PtrVectorBase {}; +template class K2Vector {}; +template class K2Vector : public K2PtrVectorBase {}; +class ScriptInfoManager { + void PostRegister() ; + template short ReplaceExistingElement(K2Vector& v); +}; +void ScriptInfoManager::PostRegister() {} From dgregor at apple.com Tue Jun 16 17:25:45 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 16 Jun 2009 22:25:45 -0000 Subject: [llvm-commits] [llvm] r73566 - /llvm/trunk/CMakeLists.txt Message-ID: <200906162225.n5GMPj3F011318@zion.cs.uiuc.edu> Author: dgregor Date: Tue Jun 16 17:25:45 2009 New Revision: 73566 URL: http://llvm.org/viewvc/llvm-project?rev=73566&view=rev Log: CMake: Only include LLVM example executables in the build if requested by the user Modified: llvm/trunk/CMakeLists.txt Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=73566&r1=73565&r2=73566&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Tue Jun 16 17:25:45 2009 @@ -287,7 +287,10 @@ add_subdirectory(projects) add_subdirectory(tools) -add_subdirectory(examples) +option(LLVM_EXAMPLES "Build LLVM example programs." OFF) +if (LLVM_EXAMPLES) + add_subdirectory(examples) +endif () install(DIRECTORY include DESTINATION . From sabre at nondot.org Tue Jun 16 17:26:14 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 22:26:14 -0000 Subject: [llvm-commits] [llvm] r73567 - /llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp Message-ID: <200906162226.n5GMQEal011339@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 17:26:13 2009 New Revision: 73567 URL: http://llvm.org/viewvc/llvm-project?rev=73567&view=rev Log: Fix the EE bindings to use the proper EE interfaces for creating a JIT. Calling into createJIT directly creates a circular dependency between libjit and lib ee. Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp?rev=73567&r1=73566&r2=73567&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngineBindings.cpp Tue Jun 16 17:26:13 2009 @@ -118,7 +118,7 @@ char **OutError) { std::string Error; if (ExecutionEngine *JIT = - ExecutionEngine::createJIT(unwrap(MP), &Error, 0, + ExecutionEngine::create(unwrap(MP), false, &Error, (CodeGenOpt::Level)OptLevel)) { *OutJIT = wrap(JIT); return 0; From isanbard at gmail.com Tue Jun 16 17:26:40 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 16 Jun 2009 22:26:40 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73569 - /llvm-gcc-4.2/trunk/gcc/Makefile.in Message-ID: <200906162226.n5GMQf8g011379@zion.cs.uiuc.edu> Author: void Date: Tue Jun 16 17:26:40 2009 New Revision: 73569 URL: http://llvm.org/viewvc/llvm-project?rev=73569&view=rev Log: --- Reverse-merging (from foreign repository) r73554 into '.': U gcc/Makefile.in Back-out patch. It was causing a bootstrap failure in Apple-style build: Undefined symbols: "__ZN4llvm19InitializeARMAsmPrinterEv", referenced from: "__ZN4llvm19InitializePowerPCTargetEv", referenced from: "__ZN4llvm19InitializePowerPCAsmPrinterEv", referenced from: "__ZN4llvm19InitializeX86AsmPrinterEv", referenced from: ld: symbol(s) not found collect2: ld returned 1 exit status Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/Makefile.in?rev=73569&r1=73568&r2=73569&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/Makefile.in (original) +++ llvm-gcc-4.2/trunk/gcc/Makefile.in Tue Jun 16 17:26:40 2009 @@ -1170,7 +1170,6 @@ # See below for more details. ifdef BUILD_LLVM_INTO_A_DYLIB LLVMTARGETOBJ := $(sort $(LLVMTARGETOBJ) x86 powerpc arm) -LLVMTARGETNAME := $(sort X86 PowerPC ARM) endif # We use llvm-config to determine the libraries that we need to link in our @@ -1233,9 +1232,7 @@ $(CXX) $(DYLIB_COMPILE_FLAGS) $(INCLUDES) -o $@ \ $< $(LLVMLIBFILES) -dynamiclib -single_module \ -compatibility_version 1.0.0 -current_version 1.0.0 \ - -install_name @executable_path/$@ \ - $(patsubst %,-u __ZN4llvm19Initialize%TargetEv,$(LLVMTARGETNAME)) \ - $(patsubst %,-u __ZN4llvm19Initialize%AsmPrinterEv,$(LLVMTARGETNAME)) \ + -install_name @executable_path/$@ LLVMBACKENDFILES := libllvmgcc$(LLVM_STAGE).dylib From sabre at nondot.org Tue Jun 16 17:38:04 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 22:38:04 -0000 Subject: [llvm-commits] [llvm] r73573 - in /llvm/trunk/lib/Target/Mips: AsmPrinter/MipsAsmPrinter.cpp MipsTargetMachine.cpp MipsTargetMachine.h Message-ID: <200906162238.n5GMc53o011893@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 17:38:04 2009 New Revision: 73573 URL: http://llvm.org/viewvc/llvm-project?rev=73573&view=rev Log: fix a circular dependency between the mips code generator and its asmprinter. Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp llvm/trunk/lib/Target/Mips/MipsTargetMachine.h Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp?rev=73573&r1=73572&r2=73573&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Tue Jun 16 17:38:04 2009 @@ -579,6 +579,14 @@ return AsmPrinter::doFinalization(M); } +namespace { + static struct Register { + Register() { + MipsTargetMachine::registerAsmPrinter(createMipsCodePrinterPass); + } + } Registrator; +} + // Force static initialization when called from // llvm/InitializeAllAsmPrinters.h namespace llvm { Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp?rev=73573&r1=73572&r2=73573&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp Tue Jun 16 17:38:04 2009 @@ -31,6 +31,9 @@ static RegisterTarget X("mips", "Mips"); static RegisterTarget Y("mipsel", "Mipsel"); +MipsTargetMachine::AsmPrinterCtorFn MipsTargetMachine::AsmPrinterCtor = 0; + + // Force static initialization when called from llvm/InitializeAllTargets.h namespace llvm { void InitializeMipsTarget() { } @@ -130,9 +133,9 @@ // true if AssemblyEmitter is supported bool MipsTargetMachine:: addAssemblyEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, - bool Verbose, raw_ostream &Out) -{ + bool Verbose, raw_ostream &Out) { // Output assembly language. - PM.add(createMipsCodePrinterPass(Out, *this, OptLevel, Verbose)); + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + PM.add(AsmPrinterCtor(Out, *this, OptLevel, Verbose)); return false; } Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.h?rev=73573&r1=73572&r2=73573&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsTargetMachine.h (original) +++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.h Tue Jun 16 17:38:04 2009 @@ -33,10 +33,23 @@ protected: virtual const TargetAsmInfo *createTargetAsmInfo() const; - + protected: + // To avoid having target depend on the asmprinter stuff libraries, + // asmprinter set this functions to ctor pointer at startup time if they are + // linked in. + typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o, + MipsTargetMachine &tm, + CodeGenOpt::Level OptLevel, + bool verbose); + static AsmPrinterCtorFn AsmPrinterCtor; + public: MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle); + static void registerAsmPrinter(AsmPrinterCtorFn F) { + AsmPrinterCtor = F; + } + virtual const MipsInstrInfo *getInstrInfo() const { return &InstrInfo; } virtual const TargetFrameInfo *getFrameInfo() const From resistor at mac.com Tue Jun 16 17:51:19 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 22:51:19 -0000 Subject: [llvm-commits] [llvm] r73575 - /llvm/trunk/lib/VMCore/Type.cpp Message-ID: <200906162251.n5GMpJGW012339@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 17:51:18 2009 New Revision: 73575 URL: http://llvm.org/viewvc/llvm-project?rev=73575&view=rev Log: Use a reader-writer lock to guard large portions of the Type infrastructure, including abstract type refinement. There's still some more work to be done here, such as guarding removeAbstractTypeUser() and the printers. Modified: llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73575&r1=73574&r2=73575&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Jun 16 17:51:18 2009 @@ -23,6 +23,8 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Threading.h" +#include "llvm/System/RWMutex.h" #include #include using namespace llvm; @@ -40,6 +42,9 @@ // Type Class Implementation //===----------------------------------------------------------------------===// +// Reader/writer lock used for guarding access to the type maps. +static ManagedStatic TypeMapLock; + // Concrete/Abstract TypeDescriptions - We lazily calculate type descriptions // for types as they are needed. Because resolution of types must invalidate // all of the abstract type descriptions, we keep them in a seperate map to make @@ -848,7 +853,7 @@ // We already have this type in the table. Get rid of the newly refined // type. TypeClass *NewTy = cast((Type*)I->second.get()); - Ty->refineAbstractTypeTo(NewTy); + Ty->unlockedRefineAbstractTypeTo(NewTy); return; } } else { @@ -884,7 +889,7 @@ } TypesByHash.erase(Entry); } - Ty->refineAbstractTypeTo(NewTy); + Ty->unlockedRefineAbstractTypeTo(NewTy); return; } } @@ -968,15 +973,40 @@ default: break; } - + IntegerValType IVT(NumBits); - IntegerType *ITy = IntegerTypes->get(IVT); - if (ITy) return ITy; // Found a match, return it! - - // Value not found. Derive a new type! - ITy = new IntegerType(NumBits); - IntegerTypes->add(IVT, ITy); + IntegerType *ITy = 0; + if (llvm_is_multithreaded()) { + // First, see if the type is already in the table, for which + // a reader lock suffices. + TypeMapLock->reader_acquire(); + ITy = IntegerTypes->get(IVT); + TypeMapLock->reader_release(); + + if (!ITy) { + // OK, not in the table, get a writer lock. + TypeMapLock->writer_acquire(); + ITy = IntegerTypes->get(IVT); + + // We need to _recheck_ the table in case someone + // put it in between when we released the reader lock + // and when we gained the writer lock! + if (!ITy) { + // Value not found. Derive a new type! + ITy = new IntegerType(NumBits); + IntegerTypes->add(IVT, ITy); + } + + TypeMapLock->writer_release(); + } + } else { + ITy = IntegerTypes->get(IVT); + if (ITy) return ITy; // Found a match, return it! + // Value not found. Derive a new type! + ITy = new IntegerType(NumBits); + IntegerTypes->add(IVT, ITy); + } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *ITy << "\n"; #endif @@ -1040,15 +1070,39 @@ const std::vector &Params, bool isVarArg) { FunctionValType VT(ReturnType, Params, isVarArg); - FunctionType *FT = FunctionTypes->get(VT); - if (FT) - return FT; - - FT = (FunctionType*) operator new(sizeof(FunctionType) + - sizeof(PATypeHandle)*(Params.size()+1)); - new (FT) FunctionType(ReturnType, Params, isVarArg); - FunctionTypes->add(VT, FT); - + FunctionType *FT = 0; + + if (llvm_is_multithreaded()) { + TypeMapLock->reader_acquire(); + FT = FunctionTypes->get(VT); + TypeMapLock->reader_release(); + + if (!FT) { + TypeMapLock->writer_acquire(); + + // Have to check again here, because it might have + // been inserted between when we release the reader + // lock and when we acquired the writer lock. + FT = FunctionTypes->get(VT); + if (!FT) { + FT = (FunctionType*) operator new(sizeof(FunctionType) + + sizeof(PATypeHandle)*(Params.size()+1)); + new (FT) FunctionType(ReturnType, Params, isVarArg); + FunctionTypes->add(VT, FT); + } + TypeMapLock->writer_release(); + } + } else { + FT = FunctionTypes->get(VT); + if (FT) + return FT; + + FT = (FunctionType*) operator new(sizeof(FunctionType) + + sizeof(PATypeHandle)*(Params.size()+1)); + new (FT) FunctionType(ReturnType, Params, isVarArg); + FunctionTypes->add(VT, FT); + } + #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << FT << "\n"; #endif @@ -1079,20 +1133,39 @@ } }; } -static ManagedStatic > ArrayTypes; +static ManagedStatic > ArrayTypes; ArrayType *ArrayType::get(const Type *ElementType, uint64_t NumElements) { assert(ElementType && "Can't get array of types!"); assert(isValidElementType(ElementType) && "Invalid type for array element!"); ArrayValType AVT(ElementType, NumElements); - ArrayType *AT = ArrayTypes->get(AVT); - if (AT) return AT; // Found a match, return it! - - // Value not found. Derive a new type! - ArrayTypes->add(AVT, AT = new ArrayType(ElementType, NumElements)); - + ArrayType *AT = 0; + + if (llvm_is_multithreaded()) { + TypeMapLock->reader_acquire(); + AT = ArrayTypes->get(AVT); + TypeMapLock->reader_release(); + + if (!AT) { + TypeMapLock->writer_acquire(); + + // Recheck. Might have changed between release and acquire. + AT = ArrayTypes->get(AVT); + if (!AT) { + // Value not found. Derive a new type! + ArrayTypes->add(AVT, AT = new ArrayType(ElementType, NumElements)); + } + TypeMapLock->writer_release(); + } + } else { + AT = ArrayTypes->get(AVT); + if (AT) return AT; // Found a match, return it! + + // Value not found. Derive a new type! + ArrayTypes->add(AVT, AT = new ArrayType(ElementType, NumElements)); + } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *AT << "\n"; #endif @@ -1136,19 +1209,36 @@ } }; } -static ManagedStatic > VectorTypes; +static ManagedStatic > VectorTypes; VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) { assert(ElementType && "Can't get vector of types!"); VectorValType PVT(ElementType, NumElements); - VectorType *PT = VectorTypes->get(PVT); - if (PT) return PT; // Found a match, return it! - - // Value not found. Derive a new type! - VectorTypes->add(PVT, PT = new VectorType(ElementType, NumElements)); - + VectorType *PT = 0; + + if (llvm_is_multithreaded()) { + TypeMapLock->reader_acquire(); + PT = VectorTypes->get(PVT); + TypeMapLock->reader_release(); + + if (!PT) { + TypeMapLock->writer_acquire(); + PT = VectorTypes->get(PVT); + // Recheck. Might have changed between release and acquire. + if (!PT) { + VectorTypes->add(PVT, PT = new VectorType(ElementType, NumElements)); + } + TypeMapLock->writer_acquire(); + } + } else { + PT = VectorTypes->get(PVT); + if (PT) return PT; // Found a match, return it! + + // Value not found. Derive a new type! + VectorTypes->add(PVT, PT = new VectorType(ElementType, NumElements)); + } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *PT << "\n"; #endif @@ -1203,15 +1293,36 @@ StructType *StructType::get(const std::vector &ETypes, bool isPacked) { StructValType STV(ETypes, isPacked); - StructType *ST = StructTypes->get(STV); - if (ST) return ST; - - // Value not found. Derive a new type! - ST = (StructType*) operator new(sizeof(StructType) + - sizeof(PATypeHandle) * ETypes.size()); - new (ST) StructType(ETypes, isPacked); - StructTypes->add(STV, ST); - + StructType *ST = 0; + + if (llvm_is_multithreaded()) { + TypeMapLock->reader_acquire(); + ST = StructTypes->get(STV); + TypeMapLock->reader_release(); + + if (!ST) { + TypeMapLock->writer_acquire(); + ST = StructTypes->get(STV); + // Recheck. Might have changed between release and acquire. + if (!ST) { + // Value not found. Derive a new type! + ST = (StructType*) operator new(sizeof(StructType) + + sizeof(PATypeHandle) * ETypes.size()); + new (ST) StructType(ETypes, isPacked); + StructTypes->add(STV, ST); + } + TypeMapLock->writer_release(); + } + } else { + ST = StructTypes->get(STV); + if (ST) return ST; + + // Value not found. Derive a new type! + ST = (StructType*) operator new(sizeof(StructType) + + sizeof(PATypeHandle) * ETypes.size()); + new (ST) StructType(ETypes, isPacked); + StructTypes->add(STV, ST); + } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *ST << "\n"; #endif @@ -1279,12 +1390,30 @@ assert(isValidElementType(ValueType) && "Invalid type for pointer element!"); PointerValType PVT(ValueType, AddressSpace); - PointerType *PT = PointerTypes->get(PVT); - if (PT) return PT; - - // Value not found. Derive a new type! - PointerTypes->add(PVT, PT = new PointerType(ValueType, AddressSpace)); - + PointerType *PT = 0; + + if (llvm_is_multithreaded()) { + TypeMapLock->reader_acquire(); + PT = PointerTypes->get(PVT); + TypeMapLock->reader_release(); + + if (!PT) { + TypeMapLock->writer_acquire(); + PT = PointerTypes->get(PVT); + // Recheck. Might have changed between release and acquire. + if (!PT) { + // Value not found. Derive a new type! + PointerTypes->add(PVT, PT = new PointerType(ValueType, AddressSpace)); + } + TypeMapLock->writer_release(); + } + } else { + PT = PointerTypes->get(PVT); + if (PT) return PT; + + // Value not found. Derive a new type! + PointerTypes->add(PVT, PT = new PointerType(ValueType, AddressSpace)); + } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *PT << "\n"; #endif @@ -1344,12 +1473,13 @@ } } -// refineAbstractTypeTo - This function is used when it is discovered that -// the 'this' abstract type is actually equivalent to the NewType specified. -// This causes all users of 'this' to switch to reference the more concrete type -// NewType and for 'this' to be deleted. +// unlockedRefineAbstractTypeTo - This function is used when it is discovered +// that the 'this' abstract type is actually equivalent to the NewType +// specified. This causes all users of 'this' to switch to reference the more +// concrete type NewType and for 'this' to be deleted. Only used for internal +// callers. // -void DerivedType::refineAbstractTypeTo(const Type *NewType) { +void DerivedType::unlockedRefineAbstractTypeTo(const Type *NewType) { assert(isAbstract() && "refineAbstractTypeTo: Current type is not abstract!"); assert(this != NewType && "Can't refine to myself!"); assert(ForwardType == 0 && "This type has already been refined!"); @@ -1368,8 +1498,7 @@ // refined, that we will not continue using a dead reference... // PATypeHolder NewTy(NewType); - - // Any PATypeHolders referring to this type will now automatically forward to + // Any PATypeHolders referring to this type will now automatically forward o // the type we are resolved to. ForwardType = NewType; if (NewType->isAbstract()) @@ -1414,6 +1543,21 @@ // destroyed. } +// refineAbstractTypeTo - This function is used by external callers to notify +// us that this abstract type is equivalent to another type. +// +void DerivedType::refineAbstractTypeTo(const Type *NewType) { + if (llvm_is_multithreaded()) { + // All recursive calls will go through unlockedRefineAbstractTypeTo, + // to avoid deadlock problems. + TypeMapLock->writer_acquire(); + unlockedRefineAbstractTypeTo(NewType); + TypeMapLock->writer_release(); + } else { + unlockedRefineAbstractTypeTo(NewType); + } +} + // notifyUsesThatTypeBecameConcrete - Notify AbstractTypeUsers of this type that // the current type has transitioned from being abstract to being concrete. // From sabre at nondot.org Tue Jun 16 17:55:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 22:55:58 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73577 - /llvm-gcc-4.2/trunk/gcc/Makefile.in Message-ID: <200906162255.n5GMtwXW012490@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 17:55:58 2009 New Revision: 73577 URL: http://llvm.org/viewvc/llvm-project?rev=73577&view=rev Log: second attempt to get arm/ppc/x86 targets linked into the apple-specific libllvmgcc.dylib. Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/Makefile.in?rev=73577&r1=73576&r2=73577&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/Makefile.in (original) +++ llvm-gcc-4.2/trunk/gcc/Makefile.in Tue Jun 16 17:55:58 2009 @@ -1170,6 +1170,15 @@ # See below for more details. ifdef BUILD_LLVM_INTO_A_DYLIB LLVMTARGETOBJ := $(sort $(LLVMTARGETOBJ) x86 powerpc arm) + + +## Target symbols to force linking. This is to ensure that the code generators +## and asm printers actually get linked into libllvmgcc.dylib. +LLVMTARGETSYMBOLS := \ + __ZN4llvm19InitializeARMTargetEv __ZN4llvm23InitializeARMAsmPrinterEv \ + __ZN4llvm23InitializePowerPCTargetEv __ZN4llvm27InitializePowerPCAsmPrinterEv\ + __ZN4llvm19InitializeX86TargetEv __ZN4llvm23InitializeX86AsmPrinterEv \ + endif # We use llvm-config to determine the libraries that we need to link in our @@ -1232,7 +1241,8 @@ $(CXX) $(DYLIB_COMPILE_FLAGS) $(INCLUDES) -o $@ \ $< $(LLVMLIBFILES) -dynamiclib -single_module \ -compatibility_version 1.0.0 -current_version 1.0.0 \ - -install_name @executable_path/$@ + -install_name @executable_path/$@ \ + $(patsubst %,-u %,$(LLVMTARGETSYMBOLS)) LLVMBACKENDFILES := libllvmgcc$(LLVM_STAGE).dylib From resistor at mac.com Tue Jun 16 17:56:04 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 16 Jun 2009 22:56:04 -0000 Subject: [llvm-commits] [llvm] r73578 - /llvm/trunk/include/llvm/DerivedTypes.h Message-ID: <200906162256.n5GMu4fd012505@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 17:56:04 2009 New Revision: 73578 URL: http://llvm.org/viewvc/llvm-project?rev=73578&view=rev Log: Forgot this file in my last commit. Modified: llvm/trunk/include/llvm/DerivedTypes.h Modified: llvm/trunk/include/llvm/DerivedTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=73578&r1=73577&r2=73578&view=diff ============================================================================== --- llvm/trunk/include/llvm/DerivedTypes.h (original) +++ llvm/trunk/include/llvm/DerivedTypes.h Tue Jun 16 17:56:04 2009 @@ -50,6 +50,10 @@ /// void dropAllTypeUses(); + /// unlockedRefineAbstractTypeTo - Internal version of refineAbstractTypeTo + /// that performs no locking. Only used for internal recursion. + void unlockedRefineAbstractTypeTo(const Type *NewType); + public: //===--------------------------------------------------------------------===// From sabre at nondot.org Tue Jun 16 18:00:42 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 16 Jun 2009 23:00:42 -0000 Subject: [llvm-commits] [llvm] r73579 - in /llvm/trunk: Makefile.rules docs/MakefileGuide.html tools/llvmc/driver/Makefile Message-ID: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 18:00:42 2009 New Revision: 73579 URL: http://llvm.org/viewvc/llvm-project?rev=73579&view=rev Log: Remove support for building LLVM libraries into "relinked" object files. Now we always build LLVM libraries into archives (.a files). This makes the 'make' build work more like the cmake build, among other things. Doing this exposed some latent circular library dependencies, so I think that llvm-config wasn't quite right for .o files anyway. Modified: llvm/trunk/Makefile.rules llvm/trunk/docs/MakefileGuide.html llvm/trunk/tools/llvmc/driver/Makefile Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=73579&r1=73578&r2=73579&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Tue Jun 16 18:00:42 2009 @@ -287,10 +287,8 @@ ifdef ENABLE_COVERAGE BuildMode := $(BuildMode)+Coverage - # These only go to .NoRelink because otherwise we will end up - # linking -lgcov into the .o libraries that get built. - CXX.Flags.NoRelink += -ftest-coverage -fprofile-arcs - C.Flags.NoRelink += -ftest-coverage -fprofile-arcs + CXX.Flags += -ftest-coverage -fprofile-arcs + C.Flags += -ftest-coverage -fprofile-arcs endif # If DISABLE_ASSERTIONS=1 is specified (make command line or configured), @@ -315,7 +313,6 @@ # defined/on. ifdef LOADABLE_MODULE SHARED_LIBRARY := 1 - DONT_BUILD_RELINKED := 1 LINK_LIBS_IN_SHARED := 1 endif @@ -548,10 +545,8 @@ endif UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %) CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS) - Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS) ifdef UNIVERSAL_SDK_PATH CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH) - Relink.Flags += -isysroot $(UNIVERSAL_SDK_PATH) endif # Building universal cannot compute dependencies automatically. @@ -582,27 +577,23 @@ $(CPP.BaseFlags) ifeq ($(BUILD_COMPONENT), 1) - Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \ + Compile.C = $(BUILD_CC) $(CPP.Flags) $(C.Flags) \ $(TargetCommonOpts) $(CompileCommonOpts) -c - Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \ + Compile.CXX = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) \ $(TargetCommonOpts) $(CompileCommonOpts) -c Preprocess.CXX= $(BUILD_CXX) $(CPP.Flags) $(TargetCommonOpts) \ - $(CompileCommonOpts) $(CXX.Flags) $(CXX.Flags.NoRelink) -E - Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \ + $(CompileCommonOpts) $(CXX.Flags) -E + Link = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) \ $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip) - Relink = $(BUILD_CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) \ - $(CompileCommonOpts) $(Relink.Flags) else - Compile.C = $(CC) $(CPP.Flags) $(C.Flags) $(C.Flags.NoRelink) \ + Compile.C = $(CC) $(CPP.Flags) $(C.Flags) \ $(TargetCommonOpts) $(CompileCommonOpts) -c - Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \ + Compile.CXX = $(CXX) $(CPP.Flags) $(CXX.Flags) \ $(TargetCommonOpts) $(CompileCommonOpts) -c Preprocess.CXX= $(CXX) $(CPP.Flags) $(TargetCommonOpts) \ - $(CompileCommonOpts) $(CXX.Flags) $(CXX.Flags.NoRelink) -E - Link = $(CXX) $(CPP.Flags) $(CXX.Flags) $(CXX.Flags.NoRelink) \ + $(CompileCommonOpts) $(CXX.Flags) -E + Link = $(CXX) $(CPP.Flags) $(CXX.Flags) \ $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) $(Strip) - Relink = $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) \ - $(CompileCommonOpts) $(Relink.Flags) endif BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(C.Flags) \ @@ -1048,48 +1039,13 @@ endif #--------------------------------------------------------- -# ReLinked Library Targets: -# If the user explicitly requests a relinked library with -# BUILD_RELINKED, provide it. Otherwise, if they specify -# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give -# them one. +# Library Targets: +# If neither BUILD_ARCHIVE or LOADABLE_MODULE are specified, default to +# building an archive. #--------------------------------------------------------- ifndef BUILD_ARCHIVE -ifndef DONT_BUILD_RELINKED -BUILD_RELINKED = 1 -endif -endif - -ifdef BUILD_RELINKED - -all-local:: $(LibName.O) - -$(LibName.O): $(ObjectsO) $(LibDir)/.dir - $(Echo) Linking $(BuildMode) Object Library $(notdir $@) - $(Verb) $(Relink) -r -nodefaultlibs -nostdlib -nostartfiles -o $@ $(ObjectsO) - -clean-local:: -ifneq ($(strip $(LibName.O)),) - -$(Verb) $(RM) -f $(LibName.O) -endif - -ifdef NO_INSTALL -install-local:: - $(Echo) Install circumvented with NO_INSTALL -uninstall-local:: - $(Echo) Uninstall circumvented with NO_INSTALL -else -DestRelinkedLib = $(PROJ_libdir)/$(LIBRARYNAME).o - -install-local:: $(DestRelinkedLib) - -$(DestRelinkedLib): $(LibName.O) $(PROJ_libdir) - $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib) - $(Verb) $(INSTALL) $(LibName.O) $(DestRelinkedLib) - -uninstall-local:: - $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib) - -$(Verb) $(RM) -f $(DestRelinkedLib) +ifndef LOADABLE_MODULE +BUILD_ARCHIVE = 1 endif endif Modified: llvm/trunk/docs/MakefileGuide.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/MakefileGuide.html?rev=73579&r1=73578&r2=73579&view=diff ============================================================================== --- llvm/trunk/docs/MakefileGuide.html (original) +++ llvm/trunk/docs/MakefileGuide.html Tue Jun 16 18:00:42 2009 @@ -232,17 +232,16 @@ Normally, the makefile system will build all the software into a single libname.o (pre-linked) object. This means the library is not searchable and that the distinction between compilation units has been - dissolved. Optionally, you can ask for a shared library (.so), archive library - (.a) or to not have the default (relinked) library built. For example:

    + dissolved. Optionally, you can ask for a shared library (.so) or archive + library (.a) built. Archive libraries are the default. For example:

    
           LIBRARYNAME = mylib
           SHARED_LIBRARY = 1
           ARCHIVE_LIBRARY = 1
    -      DONT_BUILD_RELINKED = 1
       

    says to build a library named "mylib" with both a shared library - (mylib.so) and an archive library (mylib.a) version but - not to build the relinked object (mylib.o). The contents of all the + (mylib.so) and an archive library (mylib.a) version. The + contents of all the libraries produced will be the same, they are just constructed differently. Note that you normally do not need to specify the sources involved. The LLVM Makefile system will infer the source files from the contents of the source @@ -307,8 +306,6 @@ on.

  • The LINK_LIBS_IN_SHARED variable is turned on.
  • -
  • The DONT_BUILD_RELINKED variable - is turned on.
  • A loadable module is loaded by LLVM via the facilities of libtool's libltdl library which is part of lib/System implementation.

    @@ -637,11 +634,6 @@
    If set to any value, causes the makefiles to not automatically generate dependencies when running the compiler. Use of this feature is discouraged and it may be removed at a later date.
    -
    DONT_BUILD_RELINKED
    -
    If set to any value, causes a relinked library (.o) not to be built. By - default, libraries are built as re-linked since most LLVM libraries are - needed in their entirety and re-linked libraries will be linked more quickly - than equivalent archive libraries.
    ENABLE_OPTIMIZED
    If set to any value, causes the build to generate optimized objects, libraries and executables. This alters the flags specified to the compilers @@ -960,7 +952,6 @@ DestArchiveLib DestBitcodeLib DestModule - DestRelinkedLib DestSharedLib DestTool DistAlways @@ -1004,7 +995,6 @@ ProjUsedLibs Ranlib RecursiveTargets - Relink SrcMakefiles Strip StripWarnMsg Modified: llvm/trunk/tools/llvmc/driver/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/driver/Makefile?rev=73579&r1=73578&r2=73579&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/driver/Makefile (original) +++ llvm/trunk/tools/llvmc/driver/Makefile Tue Jun 16 18:00:42 2009 @@ -10,10 +10,10 @@ LEVEL = ../../.. TOOLNAME = $(LLVMC_BASED_DRIVER_NAME) -LLVMLIBS = CompilerDriver +LLVMLIBS = CompilerDriver.a ifneq ($(LLVMC_BUILTIN_PLUGINS),) -USEDLIBS += $(patsubst %,plugin_llvmc_%,$(LLVMC_BUILTIN_PLUGINS)) +USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS)) endif LINK_COMPONENTS = support system From howard0su at gmail.com Tue Jun 16 18:32:07 2009 From: howard0su at gmail.com (Howard Su) Date: Wed, 17 Jun 2009 07:32:07 +0800 Subject: [llvm-commits] [PATCH] Change Compiler.h to make ARM target works under MSVC In-Reply-To: <847C9432-B2AF-4D24-A79E-AAB460C88BD3@apple.com> References: <847C9432-B2AF-4D24-A79E-AAB460C88BD3@apple.com> Message-ID: This patch actaully fixes this error: LLVMARMCodeGen.lib(ARMTargetMachine.cpp.obj) : error LNK2001: unresolved external symbol "public: virtual unsigned int _ _thiscall llvm::ARMTargetAsmInfo::getInlineAsmLength(char const *)const " (?getInlineAsmLengt h@?$ARMTargetAsmInfo at VTargetAsmInfo@llvm@@@llvm@@UBEIPBD at Z) ..\..\bin\llc.exe : fatal error LNK1120: 1 unresolved externals Based on MSVC document, it should support EXTERN_TEMPLATE_INSTANTIATION. See the reference link. This acutally fix the build ARM under MSVC-x86. otherwise, there is a link error. http://msdn.microsoft.com/en-us/library/7y5ca42y.aspx I am not sure if this is the best fix. On Mon, Jun 15, 2009 at 2:04 PM, Chris Lattner wrote: > > On May 21, 2009, at 5:30 AM, Howard Su wrote: > > > C++ standard (MSVC included) do support template specializations > > while it doesn't support extern template specializations. So the > > following define is wrong to me. > > #ifdef __GNUC__ > > #define EXTERN_TEMPLATE_INSTANTIATION(X) __extension__ extern > > template X > > #define TEMPLATE_INSTANTIATION(X) template X > > #else > > #define EXTERN_TEMPLATE_INSTANTIATION(X) > > #define TEMPLATE_INSTANTIATION(X) <======== wrong, C++ supports > > this. > > #endif > > Please verify. > > Hi Howard, > > Does this patch actually fix a real problem? > > -Chris > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- -Howard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/94b8efdc/attachment.html From resistor at mac.com Tue Jun 16 19:12:31 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 00:12:31 -0000 Subject: [llvm-commits] [llvm] r73586 - /llvm/trunk/lib/VMCore/Type.cpp Message-ID: <200906170012.n5H0CVZs014906@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 19:12:30 2009 New Revision: 73586 URL: http://llvm.org/viewvc/llvm-project?rev=73586&view=rev Log: Add locking around the accessors for AbstractTypeUsers. Modified: llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73586&r1=73585&r2=73586&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Jun 16 19:12:30 2009 @@ -24,6 +24,7 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Threading.h" +#include "llvm/System/Mutex.h" #include "llvm/System/RWMutex.h" #include #include @@ -45,6 +46,9 @@ // Reader/writer lock used for guarding access to the type maps. static ManagedStatic TypeMapLock; +// Lock used for guarding access to AbstractTypeUsers. +static ManagedStatic AbstractTypeUsersLock; + // Concrete/Abstract TypeDescriptions - We lazily calculate type descriptions // for types as they are needed. Because resolution of types must invalidate // all of the abstract type descriptions, we keep them in a seperate map to make @@ -1440,12 +1444,28 @@ // Derived Type Refinement Functions //===----------------------------------------------------------------------===// +// addAbstractTypeUser - Notify an abstract type that there is a new user of +// it. This function is called primarily by the PATypeHandle class. +void Type::addAbstractTypeUser(AbstractTypeUser *U) const { + assert(isAbstract() && "addAbstractTypeUser: Current type not abstract!"); + if (llvm_is_multithreaded()) { + AbstractTypeUsersLock->acquire(); + AbstractTypeUsers.push_back(U); + AbstractTypeUsersLock->release(); + } else { + AbstractTypeUsers.push_back(U); + } +} + + // removeAbstractTypeUser - Notify an abstract type that a user of the class // no longer has a handle to the type. This function is called primarily by // the PATypeHandle class. When there are no users of the abstract type, it // is annihilated, because there is no way to get a reference to it ever again. // void Type::removeAbstractTypeUser(AbstractTypeUser *U) const { + if (llvm_is_multithreaded()) AbstractTypeUsersLock->acquire(); + // Search from back to front because we will notify users from back to // front. Also, it is likely that there will be a stack like behavior to // users that register and unregister users. @@ -1469,8 +1489,11 @@ DOUT << "DELETEing unused abstract type: <" << *this << ">[" << (void*)this << "]" << "\n"; #endif - this->destroy(); + + this->destroy(); } + + if (llvm_is_multithreaded()) AbstractTypeUsersLock->release(); } // unlockedRefineAbstractTypeTo - This function is used when it is discovered From resistor at mac.com Tue Jun 16 19:13:00 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 00:13:00 -0000 Subject: [llvm-commits] [llvm] r73587 - in /llvm/trunk: autoconf/configure.ac configure include/llvm/System/Atomic.h include/llvm/Type.h lib/System/Atomic.cpp Message-ID: <200906170013.n5H0D13H014938@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 19:13:00 2009 New Revision: 73587 URL: http://llvm.org/viewvc/llvm-project?rev=73587&view=rev Log: Add an atomic increment and decrement implementation, which will be used for thread-safe reference counting. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/configure llvm/trunk/include/llvm/System/Atomic.h llvm/trunk/include/llvm/Type.h llvm/trunk/lib/System/Atomic.cpp Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=73587&r1=73586&r2=73587&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Tue Jun 16 19:13:00 2009 @@ -935,6 +935,8 @@ volatile unsigned long val = 1; __sync_synchronize(); __sync_val_compare_and_swap(&val, 1, 0); + __sync_add_and_fetch(&val, 1); + __sync_sub_and_fetch(&val, 1); return 0; } ]]), Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=73587&r1=73586&r2=73587&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Tue Jun 16 19:13:00 2009 @@ -33760,6 +33760,8 @@ volatile unsigned long val = 1; __sync_synchronize(); __sync_val_compare_and_swap(&val, 1, 0); + __sync_add_and_fetch(&val, 1); + __sync_sub_and_fetch(&val, 1); return 0; } Modified: llvm/trunk/include/llvm/System/Atomic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=73587&r1=73586&r2=73587&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Atomic.h (original) +++ llvm/trunk/include/llvm/System/Atomic.h Tue Jun 16 19:13:00 2009 @@ -24,6 +24,8 @@ cas_flag CompareAndSwap(volatile cas_flag* ptr, cas_flag new_value, cas_flag old_value); + cas_flag AtomicPostIncrement(volatile cas_flag* ptr); + cas_flag AtomicPostDecrement(volatile cas_flag* ptr); } } Modified: llvm/trunk/include/llvm/Type.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Type.h?rev=73587&r1=73586&r2=73587&view=diff ============================================================================== --- llvm/trunk/include/llvm/Type.h (original) +++ llvm/trunk/include/llvm/Type.h Tue Jun 16 19:13:00 2009 @@ -353,10 +353,7 @@ /// addAbstractTypeUser - Notify an abstract type that there is a new user of /// it. This function is called primarily by the PATypeHandle class. /// - void addAbstractTypeUser(AbstractTypeUser *U) const { - assert(isAbstract() && "addAbstractTypeUser: Current type not abstract!"); - AbstractTypeUsers.push_back(U); - } + void addAbstractTypeUser(AbstractTypeUser *U) const; /// removeAbstractTypeUser - Notify an abstract type that a user of the class /// no longer has a handle to the type. This function is called primarily by Modified: llvm/trunk/lib/System/Atomic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Atomic.cpp?rev=73587&r1=73586&r2=73587&view=diff ============================================================================== --- llvm/trunk/lib/System/Atomic.cpp (original) +++ llvm/trunk/lib/System/Atomic.cpp Tue Jun 16 19:13:00 2009 @@ -51,3 +51,31 @@ # error No compare-and-swap implementation for your platform! #endif } + +sys::cas_flag sys::AtomicPostIncrement(volatile sys::cas_flag* ptr) { +#if LLVM_MULTITHREADED==0 + ++(*ptr); + return *ptr; +#elif defined(__GNUC__) + return __sync_add_and_fetch(ptr, 1); +#elif defined(_MSC_VER) + return InterlockedCompareExchange(ptr, new_value, old_value); +#else +# error No atomic increment implementation for your platform! +#endif +} + +sys::cas_flag sys::AtomicPostDecrement(volatile sys::cas_flag* ptr) { +#if LLVM_MULTITHREADED==0 + --(*ptr); + return *ptr; +#elif defined(__GNUC__) + return __sync_sub_and_fetch(ptr, 1); +#elif defined(_MSC_VER) + return InterlockedIncrement(ptr); +#else +# error No atomic decrement implementation for your platform! +#endif +} + + From resistor at mac.com Tue Jun 16 19:28:56 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 00:28:56 -0000 Subject: [llvm-commits] [llvm] r73588 - in /llvm/trunk: include/llvm/System/Atomic.h include/llvm/Type.h lib/System/Atomic.cpp Message-ID: <200906170028.n5H0Svve015378@zion.cs.uiuc.edu> Author: resistor Date: Tue Jun 16 19:28:49 2009 New Revision: 73588 URL: http://llvm.org/viewvc/llvm-project?rev=73588&view=rev Log: Use atomic increment/decrement for reference counting of Type's. Modified: llvm/trunk/include/llvm/System/Atomic.h llvm/trunk/include/llvm/Type.h llvm/trunk/lib/System/Atomic.cpp Modified: llvm/trunk/include/llvm/System/Atomic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=73588&r1=73587&r2=73588&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Atomic.h (original) +++ llvm/trunk/include/llvm/System/Atomic.h Tue Jun 16 19:28:49 2009 @@ -24,8 +24,8 @@ cas_flag CompareAndSwap(volatile cas_flag* ptr, cas_flag new_value, cas_flag old_value); - cas_flag AtomicPostIncrement(volatile cas_flag* ptr); - cas_flag AtomicPostDecrement(volatile cas_flag* ptr); + cas_flag AtomicIncrement(volatile cas_flag* ptr); + cas_flag AtomicDecrement(volatile cas_flag* ptr); } } Modified: llvm/trunk/include/llvm/Type.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Type.h?rev=73588&r1=73587&r2=73588&view=diff ============================================================================== --- llvm/trunk/include/llvm/Type.h (original) +++ llvm/trunk/include/llvm/Type.h Tue Jun 16 19:28:49 2009 @@ -14,6 +14,7 @@ #include "llvm/AbstractTypeUser.h" #include "llvm/Support/Casting.h" #include "llvm/Support/DataTypes.h" +#include "llvm/System/Atomic.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/iterator.h" #include @@ -102,7 +103,7 @@ /// has no AbstractTypeUsers, the type is deleted. This is only sensical for /// derived types. /// - mutable unsigned RefCount; + mutable sys::cas_flag RefCount; const Type *getForwardedTypeInternal() const; @@ -337,7 +338,7 @@ void addRef() const { assert(isAbstract() && "Cannot add a reference to a non-abstract type!"); - ++RefCount; + sys::AtomicIncrement(&RefCount); } void dropRef() const { @@ -346,7 +347,8 @@ // If this is the last PATypeHolder using this object, and there are no // PATypeHandles using it, the type is dead, delete it now. - if (--RefCount == 0 && AbstractTypeUsers.empty()) + sys::cas_flag OldCount = sys::AtomicDecrement(&RefCount); + if (OldCount == 0 && AbstractTypeUsers.empty()) this->destroy(); } Modified: llvm/trunk/lib/System/Atomic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Atomic.cpp?rev=73588&r1=73587&r2=73588&view=diff ============================================================================== --- llvm/trunk/lib/System/Atomic.cpp (original) +++ llvm/trunk/lib/System/Atomic.cpp Tue Jun 16 19:28:49 2009 @@ -52,7 +52,7 @@ #endif } -sys::cas_flag sys::AtomicPostIncrement(volatile sys::cas_flag* ptr) { +sys::cas_flag sys::AtomicIncrement(volatile sys::cas_flag* ptr) { #if LLVM_MULTITHREADED==0 ++(*ptr); return *ptr; @@ -65,7 +65,7 @@ #endif } -sys::cas_flag sys::AtomicPostDecrement(volatile sys::cas_flag* ptr) { +sys::cas_flag sys::AtomicDecrement(volatile sys::cas_flag* ptr) { #if LLVM_MULTITHREADED==0 --(*ptr); return *ptr; From dgregor at apple.com Tue Jun 16 19:42:33 2009 From: dgregor at apple.com (Douglas Gregor) Date: Wed, 17 Jun 2009 00:42:33 -0000 Subject: [llvm-commits] [llvm] r73590 - /llvm/trunk/autoconf/configure.ac Message-ID: <200906170042.n5H0gXIU015833@zion.cs.uiuc.edu> Author: dgregor Date: Tue Jun 16 19:42:33 2009 New Revision: 73590 URL: http://llvm.org/viewvc/llvm-project?rev=73590&view=rev Log: Define LLVM_NATIVE_ARCH in llvm/Config/config.h to be the LLVM back end that corresponds to the native executable, but only when that LLVM back end is being built Modified: llvm/trunk/autoconf/configure.ac Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=73590&r1=73589&r2=73590&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Tue Jun 16 19:42:33 2009 @@ -234,6 +234,13 @@ AC_MSG_WARN([Configuring LLVM for an unknown target archicture]) fi +# Determine the LLVM native architecture for the target +case "$llvm_cv_target_arch" in + x86) LLVM_NATIVE_ARCH="X86" ;; + x86_64) LLVM_NATIVE_ARCH="X86" ;; + *) LLVM_NATIVE_ARCH="$llvm_cv_target_arch" ;; +esac + dnl Define a substitution, ARCH, for the target architecture AC_SUBST(ARCH,$llvm_cv_target_arch) @@ -436,6 +443,15 @@ esac AC_SUBST(TARGETS_TO_BUILD,$TARGETS_TO_BUILD) +# Determine whether we are building LLVM support for the native architecture. +# If so, define LLVM_NATIVE_ARCH to that LLVM target. +for a_target in $TARGETS_TO_BUILD; do + if test "$a_target" = "$LLVM_NATIVE_ARCH"; then + AC_DEFINE_UNQUOTED(LLVM_NATIVE_ARCH,$LLVM_NATIVE_ARCH, + [LLVM architecture name for the native architecture, if available]) + fi +done + # Build the LLVM_TARGET and LLVM_ASM_PRINTER macro uses for # Targets.def and AsmPrinters.def. LLVM_ENUM_TARGETS="" From dgregor at apple.com Tue Jun 16 19:43:21 2009 From: dgregor at apple.com (Douglas Gregor) Date: Wed, 17 Jun 2009 00:43:21 -0000 Subject: [llvm-commits] [llvm] r73591 - in /llvm/trunk: configure include/llvm/Config/config.h.in Message-ID: <200906170043.n5H0hL6M015898@zion.cs.uiuc.edu> Author: dgregor Date: Tue Jun 16 19:43:20 2009 New Revision: 73591 URL: http://llvm.org/viewvc/llvm-project?rev=73591&view=rev Log: Update auto-generated configuration files Modified: llvm/trunk/configure llvm/trunk/include/llvm/Config/config.h.in Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=73591&r1=73590&r2=73591&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Tue Jun 16 19:43:20 2009 @@ -2403,6 +2403,13 @@ echo "$as_me: WARNING: Configuring LLVM for an unknown target archicture" >&2;} fi +# Determine the LLVM native architecture for the target +case "$llvm_cv_target_arch" in + x86) LLVM_NATIVE_ARCH="X86" ;; + x86_64) LLVM_NATIVE_ARCH="X86" ;; + *) LLVM_NATIVE_ARCH="$llvm_cv_target_arch" ;; +esac + ARCH=$llvm_cv_target_arch @@ -4961,6 +4968,18 @@ TARGETS_TO_BUILD=$TARGETS_TO_BUILD +# Determine whether we are building LLVM support for the native architecture. +# If so, define LLVM_NATIVE_ARCH to that LLVM target. +for a_target in $TARGETS_TO_BUILD; do + if test "$a_target" = "$LLVM_NATIVE_ARCH"; then + +cat >>confdefs.h <<_ACEOF +#define LLVM_NATIVE_ARCH $LLVM_NATIVE_ARCH +_ACEOF + + fi +done + # Build the LLVM_TARGET and LLVM_ASM_PRINTER macro uses for # Targets.def and AsmPrinters.def. LLVM_ENUM_TARGETS="" @@ -10609,7 +10628,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 12775 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -14471,11 +14490,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14474: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14493: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14478: \$? = $ac_status" >&5 + echo "$as_me:14497: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14739,11 +14758,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14742: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14761: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:14746: \$? = $ac_status" >&5 + echo "$as_me:14765: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14843,11 +14862,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14846: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14865: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14850: \$? = $ac_status" >&5 + echo "$as_me:14869: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17295,7 +17314,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:19785: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:19770: \$? = $ac_status" >&5 + echo "$as_me:19789: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -19867,11 +19886,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:19870: $lt_compile\"" >&5) + (eval echo "\"\$as_me:19889: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:19874: \$? = $ac_status" >&5 + echo "$as_me:19893: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -21437,11 +21456,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21440: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21459: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:21444: \$? = $ac_status" >&5 + echo "$as_me:21463: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -21541,11 +21560,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:21544: $lt_compile\"" >&5) + (eval echo "\"\$as_me:21563: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:21548: \$? = $ac_status" >&5 + echo "$as_me:21567: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -23776,11 +23795,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:23779: $lt_compile\"" >&5) + (eval echo "\"\$as_me:23798: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:23783: \$? = $ac_status" >&5 + echo "$as_me:23802: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24044,11 +24063,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24047: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24066: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:24051: \$? = $ac_status" >&5 + echo "$as_me:24070: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -24148,11 +24167,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:24151: $lt_compile\"" >&5) + (eval echo "\"\$as_me:24170: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:24155: \$? = $ac_status" >&5 + echo "$as_me:24174: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized 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=73591&r1=73590&r2=73591&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.in (original) +++ llvm/trunk/include/llvm/Config/config.h.in Tue Jun 16 19:43:20 2009 @@ -476,6 +476,9 @@ /* Build multithreading support into LLVM */ #undef LLVM_MULTITHREADED +/* LLVM architecture name for the native architecture, if available */ +#undef LLVM_NATIVE_ARCH + /* Define if this is Unixish platform */ #undef LLVM_ON_UNIX From dpatel at apple.com Tue Jun 16 19:48:26 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 17 Jun 2009 00:48:26 -0000 Subject: [llvm-commits] [llvm] r73592 - /llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200906170048.n5H0mQvF016069@zion.cs.uiuc.edu> Author: dpatel Date: Tue Jun 16 19:48:26 2009 New Revision: 73592 URL: http://llvm.org/viewvc/llvm-project?rev=73592&view=rev Log: Do not use first actual instruction's location for prologue. The debug wants to skip prologue while setting a breakpoint for the function. Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=73592&r1=73591&r2=73592&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Tue Jun 16 19:48:26 2009 @@ -729,8 +729,7 @@ bool needsFrameMoves = (MMI && MMI->hasDebugInfo()) || !Fn->doesNotThrow() || UnwindTablesMandatory; - DebugLoc DL = (MBBI != MBB.end() ? MBBI->getDebugLoc() : - DebugLoc::getUnknownLoc()); + DebugLoc DL; // Prepare for frame info. unsigned FrameLabelId = 0; From dalej at apple.com Tue Jun 16 20:01:31 2009 From: dalej at apple.com (Dale Johannesen) Date: Wed, 17 Jun 2009 01:01:31 -0000 Subject: [llvm-commits] [test-suite] r73593 - /test-suite/trunk/MultiSource/Applications/ClamAV/clamav-config.h Message-ID: <200906170101.n5H11V1Z016502@zion.cs.uiuc.edu> Author: johannes Date: Tue Jun 16 20:01:31 2009 New Revision: 73593 URL: http://llvm.org/viewvc/llvm-project?rev=73593&view=rev Log: Make the command line override for FPU_WORDS_BIGENDIAN actually work. This doesn't affect behavior on PPC though. Modified: test-suite/trunk/MultiSource/Applications/ClamAV/clamav-config.h Modified: test-suite/trunk/MultiSource/Applications/ClamAV/clamav-config.h URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/ClamAV/clamav-config.h?rev=73593&r1=73592&r2=73593&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Applications/ClamAV/clamav-config.h (original) +++ test-suite/trunk/MultiSource/Applications/ClamAV/clamav-config.h Tue Jun 16 20:01:31 2009 @@ -92,7 +92,9 @@ #define FILEBUFF 8192 /* FPU byte ordering is little endian */ +#ifndef FPU_WORDS_BIGENDIAN #define FPU_WORDS_BIGENDIAN 0 +#endif /* enable workaround for broken DNS servers */ /* #undef FRESHCLAM_DNS_FIX */ From gohman at apple.com Tue Jun 16 20:22:40 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Jun 2009 01:22:40 -0000 Subject: [llvm-commits] [llvm] r73594 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/xor-and.ll Message-ID: <200906170122.n5H1Me56017548@zion.cs.uiuc.edu> Author: djg Date: Tue Jun 16 20:22:39 2009 New Revision: 73594 URL: http://llvm.org/viewvc/llvm-project?rev=73594&view=rev Log: Fix ScalarEvolution's Xor handling to not assume that an And that gets recognized with a SCEVZeroExtendExpr must be an And with a low-bits mask. With r73540, this is no longer the case. Added: llvm/trunk/test/Analysis/ScalarEvolution/xor-and.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=73594&r1=73593&r2=73594&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Jun 16 20:22:39 2009 @@ -2453,9 +2453,12 @@ if (BO->getOpcode() == Instruction::And && LCI->getValue() == CI->getValue()) if (const SCEVZeroExtendExpr *Z = - dyn_cast(getSCEV(U->getOperand(0)))) - return getZeroExtendExpr(getNotSCEV(Z->getOperand()), - U->getType()); + dyn_cast(getSCEV(U->getOperand(0)))) { + SCEVHandle ZO = Z->getOperand(); + if (APIntOps::isMask(getTypeSizeInBits(ZO->getType()), + CI->getValue())) + return getZeroExtendExpr(getNotSCEV(ZO), U->getType()); + } } break; Added: llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll?rev=73594&view=auto ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll (added) +++ llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll Tue Jun 16 20:22:39 2009 @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | opt -scalar-evolution -disable-output -analyze | grep {\\--> %z} + +; ScalarEvolution shouldn't try to analyze %s into something like +; --> (zext i4 (-1 + (-1 * (trunc i64 (8 * %x) to i4))) to i64) + +define i64 @foo(i64 %x) { + %a = shl i64 %x, 3 + %t = and i64 %a, 8 + %z = xor i64 %t, 8 + ret i64 %z +} From anton at korobeynikov.info Tue Jun 16 20:45:11 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 17 Jun 2009 05:45:11 +0400 Subject: [llvm-commits] [llvm] r73587 - in /llvm/trunk: autoconf/configure.ac configure include/llvm/System/Atomic.h include/llvm/Type.h lib/System/Atomic.cpp In-Reply-To: <200906170013.n5H0D13H014938@zion.cs.uiuc.edu> References: <200906170013.n5H0D13H014938@zion.cs.uiuc.edu> Message-ID: Hi, Owen > +sys::cas_flag sys::AtomicPostIncrement(volatile sys::cas_flag* ptr) { > +#if LLVM_MULTITHREADED==0 > + ?++(*ptr); > + ?return *ptr; > +#elif defined(__GNUC__) > + ?return __sync_add_and_fetch(ptr, 1); > +#elif defined(_MSC_VER) > + ?return InterlockedCompareExchange(ptr, new_value, old_value); > +#else > +# ?error No atomic increment implementation for your platform! > +#endif Do not forget about mingw32! If you use gcc 3.4.6 there, then there will be no atomic builtins, but you can sure use mentioned windows API calls (_MSC_VER is not defined there). -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From sabre at nondot.org Tue Jun 16 21:15:42 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Jun 2009 02:15:42 -0000 Subject: [llvm-commits] [llvm] r73595 - /llvm/trunk/tools/lli/lli.cpp Message-ID: <200906170215.n5H2FgjM019106@zion.cs.uiuc.edu> Author: lattner Date: Tue Jun 16 21:15:40 2009 New Revision: 73595 URL: http://llvm.org/viewvc/llvm-project?rev=73595&view=rev Log: Use Doug's new LLVM_NATIVE_ARCH macro in config.h to link in the native target so that the JIT works in LLI, not just the interpreter. Modified: llvm/trunk/tools/lli/lli.cpp Modified: llvm/trunk/tools/lli/lli.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=73595&r1=73594&r2=73595&view=diff ============================================================================== --- llvm/trunk/tools/lli/lli.cpp (original) +++ llvm/trunk/tools/lli/lli.cpp Tue Jun 16 21:15:40 2009 @@ -28,6 +28,7 @@ #include "llvm/Support/PrettyStackTrace.h" #include "llvm/System/Process.h" #include "llvm/System/Signals.h" +#include "llvm/Config/config.h" #include #include using namespace llvm; @@ -84,6 +85,16 @@ llvm_shutdown(); } +#ifdef LLVM_NATIVE_ARCH +namespace llvm { +#define Declare2(TARG, MOD) void Initialize ## TARG ## MOD() +#define Declare(T, M) Declare2(T, M) + Declare(LLVM_NATIVE_ARCH, Target); +#undef Declare +#undef Declare2 +} +#endif + //===----------------------------------------------------------------------===// // main Driver function // @@ -137,6 +148,16 @@ case '2': OLvl = CodeGenOpt::Default; break; case '3': OLvl = CodeGenOpt::Aggressive; break; } + + // If we have a native target, initialize it to ensure it is linked in. +#ifdef LLVM_NATIVE_ARCH +#define DoInit2(TARG, MOD) llvm::Initialize ## TARG ## MOD() +#define DoInit(T, M) DoInit2(T, M) + DoInit(LLVM_NATIVE_ARCH, Target); +#undef DoInit +#undef DoInit2 +#endif + EE = ExecutionEngine::create(MP, ForceInterpreter, &ErrorMsg, OLvl); if (!EE && !ErrorMsg.empty()) { From eocallaghan at auroraux.org Tue Jun 16 21:24:18 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Wed, 17 Jun 2009 03:24:18 +0100 Subject: [llvm-commits] [PATCH] Remove GNU particuliers from NewNightlyTest.pl , more system portable. Message-ID: <521640720906161924k31f5f0c6he19dc71598ed5d8a@mail.gmail.com> Good evening all, http://junk.auroraux.org/NewNightlyTest.pl.patch Just clean up some 'Linux only'ness' from NewNightlyTest.pl so that its usage of external tools conform to OpenGroup standards: http://www.opengroup.org/onlinepubs/009695399/utilities/find.html Please commit. Thanks for your time, Cheers, Edward. -- -- Edward O'Callaghan http://www.auroraux.org/ eocallaghan at auroraux dot org From foldr at codedgers.com Tue Jun 16 21:56:19 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Wed, 17 Jun 2009 02:56:19 -0000 Subject: [llvm-commits] [llvm] r73596 - in /llvm/trunk/tools/llvmc/doc: LLVMC-Reference.rst LLVMC-Tutorial.rst Message-ID: <200906170256.n5H2uLmQ020399@zion.cs.uiuc.edu> Author: foldr Date: Tue Jun 16 21:56:08 2009 New Revision: 73596 URL: http://llvm.org/viewvc/llvm-project?rev=73596&view=rev Log: Another small documentation update. Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst llvm/trunk/tools/llvmc/doc/LLVMC-Tutorial.rst Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst?rev=73596&r1=73595&r2=73596&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst (original) +++ llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Tue Jun 16 21:56:08 2009 @@ -33,7 +33,7 @@ Because LLVMC employs TableGen_ as its configuration language, you need to be familiar with it to customize LLVMC. -.. _TableGen: http://llvm.cs.uiuc.edu/docs/TableGenFundamentals.html +.. _TableGen: http://llvm.org/docs/TableGenFundamentals.html Compiling with LLVMC @@ -48,12 +48,12 @@ $ ./a.out hello -One nice feature of LLVMC is that one doesn't have to distinguish -between different compilers for different languages (think ``g++`` and -``gcc``) - the right toolchain is chosen automatically based on input -language names (which are, in turn, determined from file -extensions). If you want to force files ending with ".c" to compile as -C++, use the ``-x`` option, just like you would do it with ``gcc``:: +One nice feature of LLVMC is that one doesn't have to distinguish between +different compilers for different languages (think ``g++`` vs. ``gcc``) - the +right toolchain is chosen automatically based on input language names (which +are, in turn, determined from file extensions). If you want to force files +ending with ".c" to compile as C++, use the ``-x`` option, just like you would +do it with ``gcc``:: $ # hello.c is really a C++ file $ llvmc -x c++ hello.c @@ -148,13 +148,13 @@ To build your plugin as a dynamic library, just ``cd`` to its source directory and run ``make``. The resulting file will be called -``LLVMC$(LLVMC_PLUGIN).$(DLL_EXTENSION)`` (in our case, -``LLVMCMyPlugin.so``). This library can be then loaded in with the +``plugin_llvmc_$(LLVMC_PLUGIN).$(DLL_EXTENSION)`` (in our case, +``plugin_llvmc_MyPlugin.so``). This library can be then loaded in with the ``-load`` option. Example:: $ cd $LLVMC_DIR/plugins/Simple $ make - $ llvmc -load $LLVM_DIR/Release/lib/LLVMCSimple.so + $ llvmc -load $LLVM_DIR/Release/lib/plugin_llvmc_Simple.so Compiling standalone LLVMC-based drivers ======================================== @@ -187,7 +187,7 @@ $ cd $LLVMC_DIR $ make LLVMC_BUILTIN_PLUGINS=MyPlugin LLVMC_BASED_DRIVER_NAME=mydriver -This works with both srcdir==objdir and srcdir != objdir, but assumes that the +This works with both srcdir == objdir and srcdir != objdir, but assumes that the plugin source directory was placed under ``$LLVMC_DIR/plugins``. Sometimes, you will want a 'bare-bones' version of LLVMC that has no Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Tutorial.rst URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/doc/LLVMC-Tutorial.rst?rev=73596&r1=73595&r2=73596&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/doc/LLVMC-Tutorial.rst (original) +++ llvm/trunk/tools/llvmc/doc/LLVMC-Tutorial.rst Tue Jun 16 21:56:08 2009 @@ -46,12 +46,13 @@ LLVMC plugins are written mostly using TableGen_, so you need to be familiar with it to get anything done. -.. _TableGen: http://llvm.cs.uiuc.edu/docs/TableGenFundamentals.html +.. _TableGen: http://llvm.org/docs/TableGenFundamentals.html Start by compiling ``example/Simple``, which is a primitive wrapper for ``gcc``:: $ cd $LLVM_DIR/tools/llvmc + $ cp -r example/Simple plugins/Simple # NB: A less verbose way to compile standalone LLVMC-based drivers is # described in the reference manual. From foldr at codedgers.com Tue Jun 16 21:56:48 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Wed, 17 Jun 2009 02:56:48 -0000 Subject: [llvm-commits] [llvm] r73597 - in /llvm/trunk/docs: CompilerDriver.html CompilerDriverTutorial.html Message-ID: <200906170256.n5H2unDH020435@zion.cs.uiuc.edu> Author: foldr Date: Tue Jun 16 21:56:48 2009 New Revision: 73597 URL: http://llvm.org/viewvc/llvm-project?rev=73597&view=rev Log: Regenerate. Modified: llvm/trunk/docs/CompilerDriver.html llvm/trunk/docs/CompilerDriverTutorial.html Modified: llvm/trunk/docs/CompilerDriver.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CompilerDriver.html?rev=73597&r1=73596&r2=73597&view=diff ============================================================================== --- llvm/trunk/docs/CompilerDriver.html (original) +++ llvm/trunk/docs/CompilerDriver.html Tue Jun 16 21:56:48 2009 @@ -57,7 +57,7 @@ by plugins, which can be either statically or dynamically linked. This makes it possible to easily adapt LLVMC for other purposes - for example, as a build tool for game resources.

    -

    Because LLVMC employs TableGen as its configuration language, you +

    Because LLVMC employs TableGen as its configuration language, you need to be familiar with it to customize LLVMC.

    @@ -71,12 +71,12 @@ $ ./a.out hello -

    One nice feature of LLVMC is that one doesn't have to distinguish -between different compilers for different languages (think g++ and -gcc) - the right toolchain is chosen automatically based on input -language names (which are, in turn, determined from file -extensions). If you want to force files ending with ".c" to compile as -C++, use the -x option, just like you would do it with gcc:

    +

    One nice feature of LLVMC is that one doesn't have to distinguish between +different compilers for different languages (think g++ vs. gcc) - the +right toolchain is chosen automatically based on input language names (which +are, in turn, determined from file extensions). If you want to force files +ending with ".c" to compile as C++, use the -x option, just like you would +do it with gcc:

     $ # hello.c is really a C++ file
     $ llvmc -x c++ hello.c
    @@ -158,13 +158,13 @@
     

    To build your plugin as a dynamic library, just cd to its source directory and run make. The resulting file will be called -LLVMC$(LLVMC_PLUGIN).$(DLL_EXTENSION) (in our case, -LLVMCMyPlugin.so). This library can be then loaded in with the +plugin_llvmc_$(LLVMC_PLUGIN).$(DLL_EXTENSION) (in our case, +plugin_llvmc_MyPlugin.so). This library can be then loaded in with the -load option. Example:

     $ cd $LLVMC_DIR/plugins/Simple
     $ make
    -$ llvmc -load $LLVM_DIR/Release/lib/LLVMCSimple.so
    +$ llvmc -load $LLVM_DIR/Release/lib/plugin_llvmc_Simple.so
     
    @@ -197,7 +197,7 @@ $ cd $LLVMC_DIR $ make LLVMC_BUILTIN_PLUGINS=MyPlugin LLVMC_BASED_DRIVER_NAME=mydriver -

    This works with both srcdir==objdir and srcdir != objdir, but assumes that the +

    This works with both srcdir == objdir and srcdir != objdir, but assumes that the plugin source directory was placed under $LLVMC_DIR/plugins.

    Sometimes, you will want a 'bare-bones' version of LLVMC that has no built-in plugins. It can be compiled with the following command:

    Modified: llvm/trunk/docs/CompilerDriverTutorial.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CompilerDriverTutorial.html?rev=73597&r1=73596&r2=73597&view=diff ============================================================================== --- llvm/trunk/docs/CompilerDriverTutorial.html (original) +++ llvm/trunk/docs/CompilerDriverTutorial.html Tue Jun 16 21:56:48 2009 @@ -48,12 +48,13 @@

    Using LLVMC to generate toolchain drivers

    -

    LLVMC plugins are written mostly using TableGen, so you need to +

    LLVMC plugins are written mostly using TableGen, so you need to be familiar with it to get anything done.

    Start by compiling example/Simple, which is a primitive wrapper for gcc:

     $ cd $LLVM_DIR/tools/llvmc
    +$ cp -r example/Simple plugins/Simple
     
       # NB: A less verbose way to compile standalone LLVMC-based drivers is
       # described in the reference manual.
    
    
    
    
    From eli.friedman at gmail.com  Tue Jun 16 21:57:37 2009
    From: eli.friedman at gmail.com (Eli Friedman)
    Date: Wed, 17 Jun 2009 02:57:37 -0000
    Subject: [llvm-commits] [llvm] r73598 - in /llvm/trunk:
     lib/Transforms/Scalar/InstructionCombining.cpp
     test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll
    Message-ID: <200906170257.n5H2vcEv020475@zion.cs.uiuc.edu>
    
    Author: efriedma
    Date: Tue Jun 16 21:57:36 2009
    New Revision: 73598
    
    URL: http://llvm.org/viewvc/llvm-project?rev=73598&view=rev
    Log:
    PR3439: Correct a silly mistake in the SimplifyDemandedUseBits code for 
    SRem.
    
    
    Added:
        llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll
    Modified:
        llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
    
    Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=73598&r1=73597&r2=73598&view=diff
    
    ==============================================================================
    --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
    +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jun 16 21:57:36 2009
    @@ -1336,7 +1336,7 @@
         if (ConstantInt *Rem = dyn_cast(I->getOperand(1))) {
           APInt RA = Rem->getValue().abs();
           if (RA.isPowerOf2()) {
    -        if (DemandedMask.ule(RA))    // srem won't affect demanded bits
    +        if (DemandedMask.ult(RA))    // srem won't affect demanded bits
               return I->getOperand(0);
     
             APInt LowBits = RA - 1;
    
    Added: llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll?rev=73598&view=auto
    
    ==============================================================================
    --- llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll (added)
    +++ llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll Tue Jun 16 21:57:36 2009
    @@ -0,0 +1,18 @@
    +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep srem
    +; PR3439
    +
    +define i32 @a(i32 %x) nounwind {
    +entry:
    +	%rem = srem i32 %x, 2
    +	%and = and i32 %rem, 2
    +	ret i32 %and
    +}
    +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep srem
    +; PR3439
    +
    +define i32 @a(i32 %x) nounwind {
    +entry:
    +	%rem = srem i32 %x, 2
    +	%and = and i32 %rem, 2
    +	ret i32 %and
    +}
    
    
    
    
    From eli.friedman at gmail.com  Tue Jun 16 22:05:00 2009
    From: eli.friedman at gmail.com (Eli Friedman)
    Date: Wed, 17 Jun 2009 03:05:00 -0000
    Subject: [llvm-commits] [llvm] r73599 -
     /llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll
    Message-ID: <200906170305.n5H351Bt020728@zion.cs.uiuc.edu>
    
    Author: efriedma
    Date: Tue Jun 16 22:05:00 2009
    New Revision: 73599
    
    URL: http://llvm.org/viewvc/llvm-project?rev=73599&view=rev
    Log:
    Correct an accidental duplication of the test (patch doesn't handle 
    creating new files very well).
    
    
    Modified:
        llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll
    
    Modified: llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll?rev=73599&r1=73598&r2=73599&view=diff
    
    ==============================================================================
    --- llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll (original)
    +++ llvm/trunk/test/Transforms/InstCombine/2009-06-16-SRemDemandedBits.ll Tue Jun 16 22:05:00 2009
    @@ -7,12 +7,3 @@
     	%and = and i32 %rem, 2
     	ret i32 %and
     }
    -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep srem
    -; PR3439
    -
    -define i32 @a(i32 %x) nounwind {
    -entry:
    -	%rem = srem i32 %x, 2
    -	%and = and i32 %rem, 2
    -	ret i32 %and
    -}
    
    
    
    
    From foldr at codedgers.com  Tue Jun 16 22:09:40 2009
    From: foldr at codedgers.com (Mikhail Glushenkov)
    Date: Wed, 17 Jun 2009 03:09:40 -0000
    Subject: [llvm-commits] [llvm] r73600 - /llvm/trunk/docs/CommandLine.html
    Message-ID: <200906170309.n5H39fpF020897@zion.cs.uiuc.edu>
    
    Author: foldr
    Date: Tue Jun 16 22:09:39 2009
    New Revision: 73600
    
    URL: http://llvm.org/viewvc/llvm-project?rev=73600&view=rev
    Log:
    Formatting fix.
    
    Modified:
        llvm/trunk/docs/CommandLine.html
    
    Modified: llvm/trunk/docs/CommandLine.html
    URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandLine.html?rev=73600&r1=73599&r2=73600&view=diff
    
    ==============================================================================
    --- llvm/trunk/docs/CommandLine.html (original)
    +++ llvm/trunk/docs/CommandLine.html Tue Jun 16 22:09:39 2009
    @@ -1116,9 +1116,9 @@
     initial value. (You will get an error at runtime if you don't put them in
     the right order.)
     
    -
  • The cl::location attribute where to -store the value for a parsed command line option if using external storage. See -the section on Internal vs External Storage for more +
  • The cl::location attribute where +to store the value for a parsed command line option if using external storage. +See the section on Internal vs External Storage for more information.
  • The cl::aliasopt attribute @@ -1146,6 +1146,11 @@ this macro, the first argument is the enum value, the second is the flag name, and the second is the description.
  • + + +You will get a compile time error if you try to use cl::values with a parser +that does not support it. +
  • The cl::multi_val attribute specifies that this option takes has multiple values (example: -sectalign segname sectname sectvalue). This @@ -1156,12 +1161,6 @@ multi-valued options (besides cl::ValueDisallowed, obviously).
  • - - - -You will get a compile time error if you try to use cl::values with a parser -that does not support it. -
    From foldr at codedgers.com Tue Jun 16 22:10:10 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Wed, 17 Jun 2009 03:10:10 -0000 Subject: [llvm-commits] [llvm] r73601 - /llvm/trunk/include/llvm/Support/CommandLine.h Message-ID: <200906170310.n5H3ABKU020927@zion.cs.uiuc.edu> Author: foldr Date: Tue Jun 16 22:10:10 2009 New Revision: 73601 URL: http://llvm.org/viewvc/llvm-project?rev=73601&view=rev Log: Fix comment. Modified: llvm/trunk/include/llvm/Support/CommandLine.h Modified: llvm/trunk/include/llvm/Support/CommandLine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=73601&r1=73600&r2=73601&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CommandLine.h (original) +++ llvm/trunk/include/llvm/Support/CommandLine.h Tue Jun 16 22:10:10 2009 @@ -539,7 +539,7 @@ class parser : public basic_parser { const char *ArgStr; public: - + // parse - Return true on error. bool parse(Option &O, const char *ArgName, const std::string &Arg, bool &Val); @@ -1105,7 +1105,7 @@ } }; -// multi_arg - Modifier to set the number of additional values. +// multi_val - Modifier to set the number of additional values. struct multi_val { unsigned AdditionalVals; explicit multi_val(unsigned N) : AdditionalVals(N) {} From nicholas at mxc.ca Tue Jun 16 23:23:53 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 17 Jun 2009 04:23:53 -0000 Subject: [llvm-commits] [llvm] r73602 - /llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Message-ID: <200906170423.n5H4Nr4w023092@zion.cs.uiuc.edu> Author: nicholas Date: Tue Jun 16 23:23:52 2009 New Revision: 73602 URL: http://llvm.org/viewvc/llvm-project?rev=73602&view=rev Log: Fix grammaro, and bad indentation. Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=73602&r1=73601&r2=73602&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Tue Jun 16 23:23:52 2009 @@ -720,7 +720,7 @@ } /// getImplicitType - Check to see if the specified record has an implicit -/// type which should be applied to it. This infer the type of register +/// type which should be applied to it. This will infer the type of register /// references from the register file information, for example. /// static std::vector getImplicitType(Record *R, bool NotRegisters, @@ -833,8 +833,8 @@ getEnumName(getTypeNum(0)) + "'!"); } } - } - } + } + } } return MadeChange; From sabre at nondot.org Wed Jun 17 01:31:03 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Jun 2009 06:31:03 -0000 Subject: [llvm-commits] [llvm] r73603 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200906170631.n5H6V3Kg027329@zion.cs.uiuc.edu> Author: lattner Date: Wed Jun 17 01:31:02 2009 New Revision: 73603 URL: http://llvm.org/viewvc/llvm-project?rev=73603&view=rev Log: make CreateFMul forward to CreateFMul, not CreateMul. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=73603&r1=73602&r2=73603&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Jun 17 01:31:02 2009 @@ -202,7 +202,7 @@ Value *CreateFMul(Value *LHS, Value *RHS, const char *Name = "") { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) - return Folder.CreateMul(LC, RC); + return Folder.CreateFMul(LC, RC); return Insert(BinaryOperator::CreateFMul(LHS, RHS), Name); } Value *CreateUDiv(Value *LHS, Value *RHS, const char *Name = "") { From sanjiv.gupta at microchip.com Wed Jun 17 01:47:16 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Wed, 17 Jun 2009 06:47:16 -0000 Subject: [llvm-commits] [llvm] r73605 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Message-ID: <200906170647.n5H6lGqt027957@zion.cs.uiuc.edu> Author: sgupta Date: Wed Jun 17 01:47:15 2009 New Revision: 73605 URL: http://llvm.org/viewvc/llvm-project?rev=73605&view=rev Log: >> What if my global variable was into a different address space than stack? >> > > It doesn't matter in terms of semantics: because AnalyzeGlobal > returned false, we're guaranteed the address of the global is never > taken. I wouldn't be surprised if we end up generating invalid IR in > some cases, though, because of the semantics of replaceAllUsesWith. > Do you have a testcase that breaks? > > The problem is replaceAllUsesWith asserts for type mismatch here. Try attached .bc with llvm-ld. assert(New->getType() == getType() && "replaceAllUses of value with new value of different type!"); Since stack is always on address space zero, I don't think that type of GV in a different address space is ever going to match. The other way is to allow replaceAllUsesWith to ignore address spaces while comparing types. (do we have a way to do that ?). But then such an optimization may fail the entire idea of user wanting to place a variable into different memory space. The original idea of user might be to save on the stack space (data memory) and hence he asked the variable to be placed into different memory space (program memory). So the best bet here is to deny this optimization by checking GV->getType()->getAddressSpace() == 0. Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=73605&r1=73604&r2=73605&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Wed Jun 17 01:47:15 2009 @@ -1667,11 +1667,14 @@ // // NOTE: It doesn't make sense to promote non single-value types since we // are just replacing static memory to stack memory. + // + // If the global is in different address space, don't bring it to stack. if (!GS.HasMultipleAccessingFunctions && GS.AccessingFunction && !GS.HasNonInstructionUser && GV->getType()->getElementType()->isSingleValueType() && GS.AccessingFunction->getName() == "main" && - GS.AccessingFunction->hasExternalLinkage()) { + GS.AccessingFunction->hasExternalLinkage() && + GV->getType()->getAddressSpace() == 0) { DOUT << "LOCALIZING GLOBAL: " << *GV; Instruction* FirstI = GS.AccessingFunction->getEntryBlock().begin(); const Type* ElemTy = GV->getType()->getElementType(); From nicholas at mxc.ca Wed Jun 17 01:52:11 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 17 Jun 2009 06:52:11 -0000 Subject: [llvm-commits] [llvm] r73606 - /llvm/trunk/tools/lto/LTOCodeGenerator.cpp Message-ID: <200906170652.n5H6qBJr028142@zion.cs.uiuc.edu> Author: nicholas Date: Wed Jun 17 01:52:10 2009 New Revision: 73606 URL: http://llvm.org/viewvc/llvm-project?rev=73606&view=rev Log: Fix libLTO by #include'ing the initializers for all targets and all asm printers. While I'm here, alphabetize. Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=73606&r1=73605&r2=73606&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Wed Jun 17 01:52:10 2009 @@ -16,13 +16,20 @@ #include "LTOCodeGenerator.h" -#include "llvm/Module.h" -#include "llvm/PassManager.h" -#include "llvm/Linker.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/InitializeAllTargets.h" +#include "llvm/InitializeAllAsmPrinters.h" +#include "llvm/Linker.h" +#include "llvm/Module.h" #include "llvm/ModuleProvider.h" +#include "llvm/PassManager.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Analysis/Passes.h" +#include "llvm/Analysis/LoopPass.h" +#include "llvm/Analysis/Verifier.h" #include "llvm/Bitcode/ReaderWriter.h" +#include "llvm/CodeGen/FileWriters.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/MemoryBuffer.h" @@ -30,10 +37,6 @@ #include "llvm/Support/SystemUtils.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Signals.h" -#include "llvm/Analysis/Passes.h" -#include "llvm/Analysis/LoopPass.h" -#include "llvm/Analysis/Verifier.h" -#include "llvm/CodeGen/FileWriters.h" #include "llvm/Target/SubtargetFeature.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetData.h" @@ -42,13 +45,12 @@ #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" +#include #include #include -#include #include From eli.friedman at gmail.com Wed Jun 17 01:55:28 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 16 Jun 2009 23:55:28 -0700 Subject: [llvm-commits] [llvm] r73605 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp In-Reply-To: <200906170647.n5H6lGqt027957@zion.cs.uiuc.edu> References: <200906170647.n5H6lGqt027957@zion.cs.uiuc.edu> Message-ID: On Tue, Jun 16, 2009 at 11:47 PM, Sanjiv Gupta wrote: > The problem is replaceAllUsesWith asserts for type mismatch here. Try attached .bc with llvm-ld. > > assert(New->getType() == getType() && > ? ? ? ?"replaceAllUses of value with new value of different type!"); Would you mind adding a testcase for this? -Eli From baldrick at free.fr Wed Jun 17 02:49:12 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 17 Jun 2009 09:49:12 +0200 Subject: [llvm-commits] [llvm] r73543 - in /llvm/trunk: ./ autoconf/ include/llvm/ include/llvm/Config/ lib/Target/ARM/ lib/Target/ARM/AsmPrinter/ lib/Target/Alpha/ lib/Target/Alpha/AsmPrinter/ lib/Target/CBackend/ lib/Target/CellSPU/ lib/Target/CellSPU/AsmPrinter/ lib/Target/CppBackend/ lib/Target/IA64/ lib/Target/IA64/AsmPrinter/ lib/Target/MSIL/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/Mips/AsmPrinter/ lib/Target/PIC16/ lib/Target/PowerPC/ lib/Target/PowerPC/AsmPrinter/ lib/Target/Sparc/ lib/Target/Sparc/AsmPrinter/ li... In-Reply-To: <200906162012.n5GKCV4S006145@zion.cs.uiuc.edu> References: <200906162012.n5GKCV4S006145@zion.cs.uiuc.edu> Message-ID: <4A389FF8.7030802@free.fr> Hi Douglas, > +// Force static initialization when called from > +// llvm/InitializeAllAsmPrinters.h Is there some reason why this comment is line wrapped but the other copies of it are not? > Modified: llvm/trunk/tools/llc/llc.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=73543&r1=73542&r2=73543&view=diff > > ============================================================================== > --- llvm/trunk/tools/llc/llc.cpp (original) > +++ llvm/trunk/tools/llc/llc.cpp Tue Jun 16 15:12:29 2009 > @@ -38,6 +38,8 @@ > #include "llvm/System/Signals.h" > #include "llvm/Config/config.h" > #include "llvm/LinkAllVMCore.h" > +#include "llvm/InitializeAllTargets.h" > +#include "llvm/InitializeAllAsmPrinters.h" Does this mean that you now have to build all targets if you want to use llc? Ciao, Duncan. From baldrick at free.fr Wed Jun 17 02:52:13 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 17 Jun 2009 09:52:13 +0200 Subject: [llvm-commits] [llvm] r73545 - in /llvm/trunk: include/llvm/System/RWMutex.h lib/System/RWMutex.cpp lib/System/Unix/RWMutex.inc lib/System/Win32/Mutex.inc lib/System/Win32/RWMutex.inc In-Reply-To: <200906162019.n5GKJScH006431@zion.cs.uiuc.edu> References: <200906162019.n5GKJScH006431@zion.cs.uiuc.edu> Message-ID: <4A38A0AD.9000402@free.fr> Hi Owen, > + /// Attempts to unconditionally acquire the lock in reader mode. If the > + /// lock is held by a writer, this method will wait until it can acquire > + /// the lock. > + /// @returns false if any kind of error occurs, true otherwise. > + /// @brief Unconditionally acquire the lock in reader mode. > + bool reader_acquire(); what kind of error can occur? Taking a quick glance at the implementation, it looks like failure means that the platform doesn't support pthreads. In that case, wouldn't it be better to abort rather than returning an error result that probably no-one will ever check? Ciao, Duncan. From baldrick at free.fr Wed Jun 17 02:55:13 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 17 Jun 2009 09:55:13 +0200 Subject: [llvm-commits] [PATCH] Tail recursion elimination and memory loads. In-Reply-To: <4A380565.5050203@wxs.nl> References: <4A380565.5050203@wxs.nl> Message-ID: <4A38A161.8020208@free.fr> Hi Frits, > 2) The load is non-volatile, the call does not write to memory, and the > pointer isSafeToLoadUnconditionally() at that point in the code. In this > case, the load has no side-effects (and won't trap) and the memory it > loads from won't contain different data after the call, making it safe > to raise the load above the call. shouldn't isSafeToLoadUnconditionally() check that the load is not volatile? If you are loading from i/o memory, then the fact of executing the load could cause your rocket to launch - in any case it is not in general safe to LoadUnconditionally something volatile. Ciao, Duncan. From howard0su at gmail.com Wed Jun 17 03:02:18 2009 From: howard0su at gmail.com (Howard Su) Date: Wed, 17 Jun 2009 16:02:18 +0800 Subject: [llvm-commits] [llvm] r73545 - in /llvm/trunk: include/llvm/System/RWMutex.h lib/System/RWMutex.cpp lib/System/Unix/RWMutex.inc lib/System/Win32/Mutex.inc lib/System/Win32/RWMutex.inc In-Reply-To: <200906162019.n5GKJScH006431@zion.cs.uiuc.edu> References: <200906162019.n5GKJScH006431@zion.cs.uiuc.edu> Message-ID: constructore is mismatch between declare and implementation: +RWMutex::RWMutex( bool recursive) { } ^^^^^^^^^^^^^^ Also you forgot to update CMakefile.txt. On Wed, Jun 17, 2009 at 4:19 AM, Owen Anderson wrote: > Author: resistor > Date: Tue Jun 16 15:19:28 2009 > New Revision: 73545 > > URL: http://llvm.org/viewvc/llvm-project?rev=73545&view=rev > Log: > Add a portable wrapper for reader-writer locks. > > Added: > llvm/trunk/include/llvm/System/RWMutex.h > llvm/trunk/lib/System/RWMutex.cpp > llvm/trunk/lib/System/Unix/RWMutex.inc > llvm/trunk/lib/System/Win32/RWMutex.inc > Modified: > llvm/trunk/lib/System/Win32/Mutex.inc > > Added: llvm/trunk/include/llvm/System/RWMutex.h > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/RWMutex.h?rev=73545&view=auto > > > ============================================================================== > --- llvm/trunk/include/llvm/System/RWMutex.h (added) > +++ llvm/trunk/include/llvm/System/RWMutex.h Tue Jun 16 15:19:28 2009 > @@ -0,0 +1,84 @@ > +//===- RWMutex.h - Reader/Writer Mutual Exclusion Lock ----------*- C++ > -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > > +//===----------------------------------------------------------------------===// > +// > +// This file declares the llvm::sys::RWMutex class. > +// > > +//===----------------------------------------------------------------------===// > + > +#ifndef LLVM_SYSTEM_MUTEX_H > +#define LLVM_SYSTEM_MUTEX_H > + > +namespace llvm > +{ > + namespace sys > + { > + /// @brief Platform agnostic Mutex class. > + class RWMutex > + { > + /// @name Constructors > + /// @{ > + public: > + > + /// Initializes the lock but doesn't acquire it. > + /// @brief Default Constructor. > + explicit RWMutex(); > + > + /// Releases and removes the lock > + /// @brief Destructor > + ~RWMutex(); > + > + /// @} > + /// @name Methods > + /// @{ > + public: > + > + /// Attempts to unconditionally acquire the lock in reader mode. If > the > + /// lock is held by a writer, this method will wait until it can > acquire > + /// the lock. > + /// @returns false if any kind of error occurs, true otherwise. > + /// @brief Unconditionally acquire the lock in reader mode. > + bool reader_acquire(); > + > + /// Attempts to release the lock in reader mode. > + /// @returns false if any kind of error occurs, true otherwise. > + /// @brief Unconditionally release the lock in reader mode. > + bool reader_release(); > + > + /// Attempts to unconditionally acquire the lock in reader mode. If > the > + /// lock is held by any readers, this method will wait until it can > + /// acquire the lock. > + /// @returns false if any kind of error occurs, true otherwise. > + /// @brief Unconditionally acquire the lock in writer mode. > + bool writer_acquire(); > + > + /// Attempts to release the lock in writer mode. > + /// @returns false if any kind of error occurs, true otherwise. > + /// @brief Unconditionally release the lock in write mode. > + bool writer_release(); > + > + //@} > + /// @name Platform Dependent Data > + /// @{ > + private: > +#ifdef ENABLE_THREADS > + void* data_; ///< We don't know what the data will be > +#endif > + > + /// @} > + /// @name Do Not Implement > + /// @{ > + private: > + RWMutex(const RWMutex & original); > + void operator=(const RWMutex &); > + /// @} > + }; > + } > +} > + > +#endif > > Added: llvm/trunk/lib/System/RWMutex.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/RWMutex.cpp?rev=73545&view=auto > > > ============================================================================== > --- llvm/trunk/lib/System/RWMutex.cpp (added) > +++ llvm/trunk/lib/System/RWMutex.cpp Tue Jun 16 15:19:28 2009 > @@ -0,0 +1,169 @@ > +//===- RWMutex.cpp - Reader/Writer Mutual Exclusion Lock --------*- C++ > -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > > +//===----------------------------------------------------------------------===// > +// > +// This file implements the llvm::sys::RWMutex class. > +// > > +//===----------------------------------------------------------------------===// > + > +#include "llvm/Config/config.h" > +#include "llvm/System/RWMutex.h" > + > > +//===----------------------------------------------------------------------===// > +//=== WARNING: Implementation here must contain only TRULY operating > system > +//=== independent code. > > +//===----------------------------------------------------------------------===// > + > +#if !defined(ENABLE_THREADS) || ENABLE_THREADS == 0 > +// Define all methods as no-ops if threading is explicitly disabled > +namespace llvm { > +using namespace sys; > +RWMutex::RWMutex( bool recursive) { } > +RWMutex::~RWMutex() { } > +bool RWMutex::reader_acquire() { return true; } > +bool RWMutex::reader_release() { return true; } > +bool RWMutex::writer_acquire() { return true; } > +bool RWMutex::writer_release() { return true; } > +} > +#else > + > +#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD_RWLOCK_INIT) > + > +#include > +#include > +#include > + > +namespace llvm { > +using namespace sys; > + > + > +// This variable is useful for situations where the pthread library has > been > +// compiled with weak linkage for its interface symbols. This allows the > +// threading support to be turned off by simply not linking against > -lpthread. > +// In that situation, the value of pthread_mutex_init will be 0 and > +// consequently pthread_enabled will be false. In such situations, all the > +// pthread operations become no-ops and the functions all return false. If > +// pthread_rwlock_init does have an address, then rwlock support is > enabled. > +// Note: all LLVM tools will link against -lpthread if its available since > it > +// is configured into the LIBS variable. > +// Note: this line of code generates a warning if pthread_rwlock_init is > not > +// declared with weak linkage. It's safe to ignore the warning. > +static const bool pthread_enabled = true; > + > +// Construct a RWMutex using pthread calls > +RWMutex::RWMutex() > + : data_(0) > +{ > + if (pthread_enabled) > + { > + // Declare the pthread_rwlock data structures > + pthread_rwlock_t* rwlock = > + static_cast(malloc(sizeof(pthread_rwlock_t))); > + pthread_rwlockattr_t attr; > + > + // Initialize the rwlock attributes > + int errorcode = pthread_rwlockattr_init(&attr); > + assert(errorcode == 0); > + > +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) > && !defined(__DragonFly__) > + // Make it a process local rwlock > + errorcode = pthread_rwlockattr_setpshared(&attr, > PTHREAD_PROCESS_PRIVATE); > +#endif > + > + // Initialize the rwlock > + errorcode = pthread_rwlock_init(rwlock, &attr); > + assert(errorcode == 0); > + > + // Destroy the attributes > + errorcode = pthread_rwlockattr_destroy(&attr); > + assert(errorcode == 0); > + > + // Assign the data member > + data_ = rwlock; > + } > +} > + > +// Destruct a RWMutex > +RWMutex::~RWMutex() > +{ > + if (pthread_enabled) > + { > + pthread_rwlock_t* rwlock = static_cast(data_); > + assert(rwlock != 0); > + pthread_rwlock_destroy(rwlock); > + free(rwlock); > + } > +} > + > +bool > +RWMutex::reader_acquire() > +{ > + if (pthread_enabled) > + { > + pthread_rwlock_t* rwlock = static_cast(data_); > + assert(rwlock != 0); > + > + int errorcode = pthread_rwlock_rdlock(rwlock); > + return errorcode == 0; > + } > + return false; > +} > + > +bool > +RWMutex::reader_release() > +{ > + if (pthread_enabled) > + { > + pthread_rwlock_t* rwlock = static_cast(data_); > + assert(rwlock != 0); > + > + int errorcode = pthread_rwlock_unlock(rwlock); > + return errorcode == 0; > + } > + return false; > +} > + > +bool > +RWMutex::writer_acquire() > +{ > + if (pthread_enabled) > + { > + pthread_rwlock_t* rwlock = static_cast(data_); > + assert(rwlock != 0); > + > + int errorcode = pthread_rwlock_wrlock(rwlock); > + return errorcode == 0; > + } > + return false; > +} > + > +bool > +RWMutex::writer_release() > +{ > + if (pthread_enabled) > + { > + pthread_rwlock_t* rwlock = static_cast(data_); > + assert(rwlock != 0); > + > + int errorcode = pthread_rwlock_unlock(rwlock); > + return errorcode == 0; > + } > + return false; > +} > + > +} > + > +#elif defined(LLVM_ON_UNIX) > +#include "Unix/RWMutex.inc" > +#elif defined( LLVM_ON_WIN32) > +#include "Win32/RWMutex.inc" > +#else > +#warning Neither LLVM_ON_UNIX nor LLVM_ON_WIN32 was set in > System/Mutex.cpp > +#endif > +#endif > + > > Added: llvm/trunk/lib/System/Unix/RWMutex.inc > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/RWMutex.inc?rev=73545&view=auto > > > ============================================================================== > --- llvm/trunk/lib/System/Unix/RWMutex.inc (added) > +++ llvm/trunk/lib/System/Unix/RWMutex.inc Tue Jun 16 15:19:28 2009 > @@ -0,0 +1,43 @@ > +//= llvm/System/Unix/RWMutex.inc - Unix Reader/Writer Mutual Exclusion > Lock =// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > > +//===----------------------------------------------------------------------===// > +// > +// This file implements the Unix specific (non-pthread) RWMutex class. > +// > > +//===----------------------------------------------------------------------===// > + > > +//===----------------------------------------------------------------------===// > +//=== WARNING: Implementation here must contain only generic UNIX code > that > +//=== is guaranteed to work on *all* UNIX variants. > > +//===----------------------------------------------------------------------===// > + > +namespace llvm { > + > +using namespace sys; > + > +RWMutex::RWMutex() { } > + > +RWMutex::~RWMutex() { } > + > +bool RWMutex::reader_acquire() { > + return true; > +} > + > +bool RWMutex::reader_release() { > + return true; > +} > + > +bool RWMutex::writer_acquire() { > + return true; > +} > + > +bool RWMutex::writer_release() { > + return true; > +} > + > +} > > Modified: llvm/trunk/lib/System/Win32/Mutex.inc > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Mutex.inc?rev=73545&r1=73544&r2=73545&view=diff > > > ============================================================================== > --- llvm/trunk/lib/System/Win32/Mutex.inc (original) > +++ llvm/trunk/lib/System/Win32/Mutex.inc Tue Jun 16 15:19:28 2009 > @@ -22,7 +22,7 @@ > namespace llvm { > using namespace sys; > > -Mutex::Mutex(bool /*recursive*/) > +Mutex::Mutex() > { > data_ = new CRITICAL_SECTION; > InitializeCriticalSection((LPCRITICAL_SECTION)data_); > > Added: llvm/trunk/lib/System/Win32/RWMutex.inc > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/RWMutex.inc?rev=73545&view=auto > > > ============================================================================== > --- llvm/trunk/lib/System/Win32/RWMutex.inc (added) > +++ llvm/trunk/lib/System/Win32/RWMutex.inc Tue Jun 16 15:19:28 2009 > @@ -0,0 +1,55 @@ > +//= llvm/System/Win32/Mutex.inc - Win32 Reader/Writer Mutual Exclusion > Lock =// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > > +//===----------------------------------------------------------------------===// > +// > +// This file implements the Win32 specific (non-pthread) RWMutex class. > +// > > +//===----------------------------------------------------------------------===// > + > > +//===----------------------------------------------------------------------===// > +//=== WARNING: Implementation here must contain only generic Win32 code > that > +//=== is guaranteed to work on *all* Win32 variants. > > +//===----------------------------------------------------------------------===// > + > +#include "Win32.h" > + > +namespace llvm { > +using namespace sys; > + > +RWMutex::RWMutex() { > + data_ = new PSRWLOCK; > + InitializeSRWLock((PSRWLOCK*)data_); > +} > + > +RWMutex::~RWMutex() { > + delete (PSRWLOCK*)data_; > + data_ = 0; > +} > + > +bool RWMutex::reader_acquire() { > + AcquireSRWLockShared((PSRWLOCK*)data_); > + return true; > +} > + > +bool RWMutex::reader_release() { > + ReleaseSRWLockShared((PSRWLOCK*)data_); > + return true; > +} > + > +bool RWMutex::writer_acquire() { > + AcquireSRWLockExclusive((PSRWLOCK*)data_); > + return true; > +} > + > +bool RWMutex::writer_release() { > + ReleaseSRWLockExclusive((PSRWLOCK*)data_); > + return true; > +} > + > + > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- -Howard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/e96b87b6/attachment.html From fvbommel at wxs.nl Wed Jun 17 03:26:06 2009 From: fvbommel at wxs.nl (Frits van Bommel) Date: Wed, 17 Jun 2009 10:26:06 +0200 Subject: [llvm-commits] [PATCH] Tail recursion elimination and memory loads. In-Reply-To: <4A38A161.8020208@free.fr> References: <4A380565.5050203@wxs.nl> <4A38A161.8020208@free.fr> Message-ID: <4A38A89E.5060107@wxs.nl> Duncan Sands wrote: > Hi Frits, > >> 2) The load is non-volatile, the call does not write to memory, and the >> pointer isSafeToLoadUnconditionally() at that point in the code. In this >> case, the load has no side-effects (and won't trap) and the memory it >> loads from won't contain different data after the call, making it safe >> to raise the load above the call. > > shouldn't isSafeToLoadUnconditionally() check that the load is not > volatile? If you are loading from i/o memory, then the fact of > executing the load could cause your rocket to launch - in any case > it is not in general safe to LoadUnconditionally something volatile. isSafeToLoadUnconditionally() only receives the pointer loaded from and the instruction to start scanning from[1] so it never sees the load itself. (instcombine, the only other user, already gives up earlier if Load->isVolatile() returns true) [1]: And in the case of instcombine, the latter is a select instruction, not a load. From resistor at mac.com Wed Jun 17 04:11:08 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 09:11:08 -0000 Subject: [llvm-commits] [llvm] r73607 - /llvm/trunk/lib/System/Win32/RWMutex.inc Message-ID: <200906170911.n5H9BAj0011640@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 04:10:42 2009 New Revision: 73607 URL: http://llvm.org/viewvc/llvm-project?rev=73607&view=rev Log: Improve the Win32 reader-writer lock implementation by making it just a normal lock. This is obviously bad, but at least it's threadsafe! If you know how to improve this in a pre-Vista friendly well, patches welcome! Patch by Max Burke. Modified: llvm/trunk/lib/System/Win32/RWMutex.inc Modified: llvm/trunk/lib/System/Win32/RWMutex.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/RWMutex.inc?rev=73607&r1=73606&r2=73607&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/RWMutex.inc (original) +++ llvm/trunk/lib/System/Win32/RWMutex.inc Wed Jun 17 04:10:42 2009 @@ -18,31 +18,39 @@ #include "Win32.h" -// FIXME: THIS IS NOT THREAD-SAFE!! -// Windows does not have reader-writer locks pre-Vista. If you want to have -// thread-safe LLVM on Windows, for now at least, you need to use a pthreads -// replacement library. +// FIXME: Windows does not have reader-writer locks pre-Vista. If you want +// real reader-writer locks, you a pthreads implementation for Windows. namespace llvm { using namespace sys; -RWMutex::RWMutex() { } +RWMutex::RWMutex() { + data_ = calloc(1, sizeof(CRITICAL_SECTION)); + InitializeCriticalSection(static_cast(data_)); +} -RWMutex::~RWMutex() { } +RWMutex::~RWMutex() { + DeleteCriticalSection(static_cast(data_)); + free(data_); +} bool RWMutex::reader_acquire() { + EnterCriticalSection(static_cast(data_)); return true; } bool RWMutex::reader_release() { + LeaveCriticalSection(static_cast(data_)); return true; } bool RWMutex::writer_acquire() { + EnterCriticalSection(static_cast(data_)); return true; } bool RWMutex::writer_release() { + LeaveCriticalSection(static_cast(data_)); return true; } From howard0su at gmail.com Wed Jun 17 04:22:23 2009 From: howard0su at gmail.com (Howard Su) Date: Wed, 17 Jun 2009 17:22:23 +0800 Subject: [llvm-commits] [llvm] r73607 - /llvm/trunk/lib/System/Win32/RWMutex.inc In-Reply-To: <200906170911.n5H9BAj0011640@zion.cs.uiuc.edu> References: <200906170911.n5H9BAj0011640@zion.cs.uiuc.edu> Message-ID: Maybe you can reference this: http://www.codeguru.com/cpp/w-p/system/misc/article.php/c5679 On Wed, Jun 17, 2009 at 5:11 PM, Owen Anderson wrote: > Author: resistor > Date: Wed Jun 17 04:10:42 2009 > New Revision: 73607 > > URL: http://llvm.org/viewvc/llvm-project?rev=73607&view=rev > Log: > Improve the Win32 reader-writer lock implementation by making it just a > normal > lock. This is obviously bad, but at least it's threadsafe! If you know > how > to improve this in a pre-Vista friendly well, patches welcome! > > Patch by Max Burke. > > Modified: > llvm/trunk/lib/System/Win32/RWMutex.inc > > Modified: llvm/trunk/lib/System/Win32/RWMutex.inc > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/RWMutex.inc?rev=73607&r1=73606&r2=73607&view=diff > > > ============================================================================== > --- llvm/trunk/lib/System/Win32/RWMutex.inc (original) > +++ llvm/trunk/lib/System/Win32/RWMutex.inc Wed Jun 17 04:10:42 2009 > @@ -18,31 +18,39 @@ > > #include "Win32.h" > > -// FIXME: THIS IS NOT THREAD-SAFE!! > -// Windows does not have reader-writer locks pre-Vista. If you want to > have > -// thread-safe LLVM on Windows, for now at least, you need to use a > pthreads > -// replacement library. > +// FIXME: Windows does not have reader-writer locks pre-Vista. If you > want > +// real reader-writer locks, you a pthreads implementation for Windows. > > namespace llvm { > using namespace sys; > > -RWMutex::RWMutex() { } > +RWMutex::RWMutex() { > + data_ = calloc(1, sizeof(CRITICAL_SECTION)); > + InitializeCriticalSection(static_cast(data_)); > +} > > -RWMutex::~RWMutex() { } > +RWMutex::~RWMutex() { > + DeleteCriticalSection(static_cast(data_)); > + free(data_); > +} > > bool RWMutex::reader_acquire() { > + EnterCriticalSection(static_cast(data_)); > return true; > } > > bool RWMutex::reader_release() { > + LeaveCriticalSection(static_cast(data_)); > return true; > } > > bool RWMutex::writer_acquire() { > + EnterCriticalSection(static_cast(data_)); > return true; > } > > bool RWMutex::writer_release() { > + LeaveCriticalSection(static_cast(data_)); > return true; > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- -Howard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/e3a31d7e/attachment.html From edwintorok at gmail.com Wed Jun 17 05:16:30 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 17 Jun 2009 13:16:30 +0300 Subject: [llvm-commits] [llvm] r73595 - /llvm/trunk/tools/lli/lli.cpp In-Reply-To: <200906170215.n5H2FgjM019106@zion.cs.uiuc.edu> References: <200906170215.n5H2FgjM019106@zion.cs.uiuc.edu> Message-ID: <4A38C27E.5070505@gmail.com> On 2009-06-17 05:15, Chris Lattner wrote: > Author: lattner > Date: Tue Jun 16 21:15:40 2009 > New Revision: 73595 > > URL: http://llvm.org/viewvc/llvm-project?rev=73595&view=rev > Log: > Use Doug's new LLVM_NATIVE_ARCH macro in config.h to link in the native > target so that the JIT works in LLI, not just the interpreter. > Hi Chris, Is this something that every JIT client should do? examples/BrainF segfaults, because it finds no JITs for the target. If this is something that every JIT client should do, then it would be nice to have something in ExecutionEngine.h that would ensure that the proper JIT is linked in. Best regards, --Edwin From sabre at nondot.org Wed Jun 17 11:42:05 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Jun 2009 16:42:05 -0000 Subject: [llvm-commits] [llvm] r73610 - /llvm/trunk/include/llvm/Target/TargetSelect.h Message-ID: <200906171642.n5HGg6JM027134@zion.cs.uiuc.edu> Author: lattner Date: Wed Jun 17 11:42:01 2009 New Revision: 73610 URL: http://llvm.org/viewvc/llvm-project?rev=73610&view=rev Log: Add a utility header that makes it easy to link in the right set of targets for various purposes. Added: llvm/trunk/include/llvm/Target/TargetSelect.h Added: llvm/trunk/include/llvm/Target/TargetSelect.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSelect.h?rev=73610&view=auto ============================================================================== --- llvm/trunk/include/llvm/Target/TargetSelect.h (added) +++ llvm/trunk/include/llvm/Target/TargetSelect.h Wed Jun 17 11:42:01 2009 @@ -0,0 +1,65 @@ +//===- TargetSelect.h - Target Selection & Registration -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file provides utilities to make sure that certain classes of targets are +// linked into the main application executable, and initialize them as +// appropriate. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TARGET_TARGETSELECT_H +#define LLVM_TARGET_TARGETSELECT_H + +#include "llvm/Config/config.h" + +namespace llvm { + // Declare all of the target-initialization functions that are available. +#define LLVM_TARGET(TargetName) void Initialize##TargetName##Target(); +#include "llvm/Config/Targets.def" + + // Declare all of the available asm-printer initialization functions. + // Declare all of the target-initialization functions. +#define LLVM_ASM_PRINTER(TargetName) void Initialize##TargetName##AsmPrinter(); +#include "llvm/Config/AsmPrinters.def" + + /// InitializeAllTargets - The main program should call this function if it + /// wants to link in all available targets that LLVM is configured to support. + inline void InitializeAllTargets() { +#define LLVM_TARGET(TargetName) llvm::Initialize##TargetName##Target(); +#include "llvm/Config/Targets.def" + } + + /// InitializeAllAsmPrinters - The main program should call this function if + /// it wants all asm printers that LLVM is configured to support. This will + /// cause them to be linked into its executable. + inline void InitializeAllAsmPrinters() { +#define LLVM_ASM_PRINTER(TargetName) Initialize##TargetName##AsmPrinter(); +#include "llvm/Config/AsmPrinters.def" + } + + + /// InitializeNativeTarget - The main program should call this function to + /// initialize the native target corresponding to the host. This is useful + /// for JIT applications to ensure that the target gets linked in correctly. + inline bool InitializeNativeTarget() { + // If we have a native target, initialize it to ensure it is linked in. +#ifdef LLVM_NATIVE_ARCH +#define DoInit2(TARG, MOD) llvm::Initialize ## TARG ## MOD() +#define DoInit(T, M) DoInit2(T, M) + DoInit(LLVM_NATIVE_ARCH, Target); + return false; +#undef DoInit +#undef DoInit2 +#else + return true; +#endif + } +} + +#endif From sabre at nondot.org Wed Jun 17 11:42:19 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Jun 2009 16:42:19 -0000 Subject: [llvm-commits] [llvm] r73611 - in /llvm/trunk/tools: llc/llc.cpp lli/lli.cpp lto/LTOCodeGenerator.cpp Message-ID: <200906171642.n5HGgJr9027153@zion.cs.uiuc.edu> Author: lattner Date: Wed Jun 17 11:42:19 2009 New Revision: 73611 URL: http://llvm.org/viewvc/llvm-project?rev=73611&view=rev Log: switch to using llvm/Target/TargetSelect.h Modified: llvm/trunk/tools/llc/llc.cpp llvm/trunk/tools/lli/lli.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp Modified: llvm/trunk/tools/llc/llc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=73611&r1=73610&r2=73611&view=diff ============================================================================== --- llvm/trunk/tools/llc/llc.cpp (original) +++ llvm/trunk/tools/llc/llc.cpp Wed Jun 17 11:42:19 2009 @@ -38,8 +38,7 @@ #include "llvm/System/Signals.h" #include "llvm/Config/config.h" #include "llvm/LinkAllVMCore.h" -#include "llvm/InitializeAllTargets.h" -#include "llvm/InitializeAllAsmPrinters.h" +#include "llvm/Target/TargetSelect.h" #include #include #include @@ -216,6 +215,9 @@ llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n"); + InitializeAllTargets(); + InitializeAllAsmPrinters(); + // Load the module to be compiled... std::string ErrorMessage; std::auto_ptr M; Modified: llvm/trunk/tools/lli/lli.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=73611&r1=73610&r2=73611&view=diff ============================================================================== --- llvm/trunk/tools/lli/lli.cpp (original) +++ llvm/trunk/tools/lli/lli.cpp Wed Jun 17 11:42:19 2009 @@ -28,7 +28,7 @@ #include "llvm/Support/PrettyStackTrace.h" #include "llvm/System/Process.h" #include "llvm/System/Signals.h" -#include "llvm/Config/config.h" +#include "llvm/Target/TargetSelect.h" #include #include using namespace llvm; @@ -85,16 +85,6 @@ llvm_shutdown(); } -#ifdef LLVM_NATIVE_ARCH -namespace llvm { -#define Declare2(TARG, MOD) void Initialize ## TARG ## MOD() -#define Declare(T, M) Declare2(T, M) - Declare(LLVM_NATIVE_ARCH, Target); -#undef Declare -#undef Declare2 -} -#endif - //===----------------------------------------------------------------------===// // main Driver function // @@ -149,15 +139,9 @@ case '3': OLvl = CodeGenOpt::Aggressive; break; } - // If we have a native target, initialize it to ensure it is linked in. -#ifdef LLVM_NATIVE_ARCH -#define DoInit2(TARG, MOD) llvm::Initialize ## TARG ## MOD() -#define DoInit(T, M) DoInit2(T, M) - DoInit(LLVM_NATIVE_ARCH, Target); -#undef DoInit -#undef DoInit2 -#endif - + // If we have a native target, initialize it to ensure it is linked in and + // usable by the JIT. + InitializeNativeTarget(); EE = ExecutionEngine::create(MP, ForceInterpreter, &ErrorMsg, OLvl); if (!EE && !ErrorMsg.empty()) { Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=73611&r1=73610&r2=73611&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Wed Jun 17 11:42:19 2009 @@ -18,8 +18,6 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" -#include "llvm/InitializeAllTargets.h" -#include "llvm/InitializeAllAsmPrinters.h" #include "llvm/Linker.h" #include "llvm/Module.h" #include "llvm/ModuleProvider.h" @@ -39,10 +37,11 @@ #include "llvm/System/Signals.h" #include "llvm/Target/SubtargetFeature.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachineRegistry.h" -#include "llvm/Target/TargetAsmInfo.h" +#include "llvm/Target/TargetSelect.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Config/config.h" @@ -76,6 +75,8 @@ _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), _nativeObjectFile(NULL), _gccPath(NULL), _assemblerPath(NULL) { + InitializeAllTargets(); + InitializeAllAsmPrinters(); } From sabre at nondot.org Wed Jun 17 11:45:03 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Jun 2009 16:45:03 -0000 Subject: [llvm-commits] [llvm] r73612 - in /llvm/trunk/include/llvm: InitializeAllAsmPrinters.h InitializeAllTargets.h Message-ID: <200906171645.n5HGj5K3027254@zion.cs.uiuc.edu> Author: lattner Date: Wed Jun 17 11:45:02 2009 New Revision: 73612 URL: http://llvm.org/viewvc/llvm-project?rev=73612&view=rev Log: remove two headers subsumed by TargetSelect.h Removed: llvm/trunk/include/llvm/InitializeAllAsmPrinters.h llvm/trunk/include/llvm/InitializeAllTargets.h Removed: llvm/trunk/include/llvm/InitializeAllAsmPrinters.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializeAllAsmPrinters.h?rev=73611&view=auto ============================================================================== --- llvm/trunk/include/llvm/InitializeAllAsmPrinters.h (original) +++ llvm/trunk/include/llvm/InitializeAllAsmPrinters.h (removed) @@ -1,34 +0,0 @@ -//===- llvm/InitializeAllAsmPrinters.h - Init Asm Printers ------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This header initializes all assembler printers for all configured -// LLVM targets, ensuring that they are registered. -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_INITIALIZE_ALL_ASM_PRINTERS_H -#define LLVM_INITIALIZE_ALL_ASM_PRINTERS_H - -namespace llvm { - - // Declare all of the target-initialization functions. -#define LLVM_ASM_PRINTER(TargetName) void Initialize##TargetName##AsmPrinter(); -#include "llvm/Config/AsmPrinters.def" - - namespace { - struct InitializeAllAsmPrinters { - InitializeAllAsmPrinters() { - // Call all of the target-initialization functions. -#define LLVM_ASM_PRINTER(TargetName) llvm::Initialize##TargetName##AsmPrinter(); -#include "llvm/Config/AsmPrinters.def" - } - } DoInitializeAllAsmPrinters; - } -} // end namespace llvm - -#endif // LLVM_INITIALIZE_ALL_ASM_PRINTERS_H Removed: llvm/trunk/include/llvm/InitializeAllTargets.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializeAllTargets.h?rev=73611&view=auto ============================================================================== --- llvm/trunk/include/llvm/InitializeAllTargets.h (original) +++ llvm/trunk/include/llvm/InitializeAllTargets.h (removed) @@ -1,34 +0,0 @@ -//===- llvm/InitializeAllTargets.h - Initialize All Targets -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This header initializes all configured LLVM targets, ensuring that they -// are registered. -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_INITIALIZE_ALL_TARGETS_H -#define LLVM_INITIALIZE_ALL_TARGETS_H - -namespace llvm { - - // Declare all of the target-initialization functions. -#define LLVM_TARGET(TargetName) void Initialize##TargetName##Target(); -#include "llvm/Config/Targets.def" - - namespace { - struct InitializeAllTargets { - InitializeAllTargets() { - // Call all of the target-initialization functions. -#define LLVM_TARGET(TargetName) llvm::Initialize##TargetName##Target(); -#include "llvm/Config/Targets.def" - } - } DoInitializeAllTargets; - } -} // end namespace llvm - -#endif // LLVM_INITIALIZE_ALL_TARGETS_H From sabre at nondot.org Wed Jun 17 11:48:45 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 17 Jun 2009 16:48:45 -0000 Subject: [llvm-commits] [llvm] r73613 - in /llvm/trunk/examples: BrainF/BrainFDriver.cpp HowToUseJIT/HowToUseJIT.cpp Kaleidoscope/toy.cpp ParallelJIT/ParallelJIT.cpp Message-ID: <200906171648.n5HGmjZx027373@zion.cs.uiuc.edu> Author: lattner Date: Wed Jun 17 11:48:44 2009 New Revision: 73613 URL: http://llvm.org/viewvc/llvm-project?rev=73613&view=rev Log: make sure that JIT examples link in their appropriate target. Modified: llvm/trunk/examples/BrainF/BrainFDriver.cpp llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp llvm/trunk/examples/Kaleidoscope/toy.cpp llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp Modified: llvm/trunk/examples/BrainF/BrainFDriver.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainFDriver.cpp?rev=73613&r1=73612&r2=73613&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainFDriver.cpp (original) +++ llvm/trunk/examples/BrainF/BrainFDriver.cpp Wed Jun 17 11:48:44 2009 @@ -34,6 +34,7 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Target/TargetSelect.h" #include #include using namespace llvm; @@ -135,6 +136,8 @@ //Write it out if (JIT) { + InitializeNativeTarget(); + std::cout << "------- Running JIT -------\n"; ExistingModuleProvider *mp = new ExistingModuleProvider(mod); ExecutionEngine *ee = ExecutionEngine::create(mp, false); Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp?rev=73613&r1=73612&r2=73613&view=diff ============================================================================== --- llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp (original) +++ llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp Wed Jun 17 11:48:44 2009 @@ -42,11 +42,15 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/GenericValue.h" +#include "llvm/Target/TargetSelect.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; int main() { + + InitializeNativeTarget(); + // Create some module to put our function into it. Module *M = new Module("test"); Modified: llvm/trunk/examples/Kaleidoscope/toy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/toy.cpp?rev=73613&r1=73612&r2=73613&view=diff ============================================================================== --- llvm/trunk/examples/Kaleidoscope/toy.cpp (original) +++ llvm/trunk/examples/Kaleidoscope/toy.cpp Wed Jun 17 11:48:44 2009 @@ -5,6 +5,7 @@ #include "llvm/PassManager.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetSelect.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Support/IRBuilder.h" #include @@ -1081,6 +1082,8 @@ //===----------------------------------------------------------------------===// int main() { + InitializeNativeTarget(); + // Install standard binary operators. // 1 is lowest precedence. BinopPrecedence['='] = 2; Modified: llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp?rev=73613&r1=73612&r2=73613&view=diff ============================================================================== --- llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp (original) +++ llvm/trunk/examples/ParallelJIT/ParallelJIT.cpp Wed Jun 17 11:48:44 2009 @@ -26,6 +26,7 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/GenericValue.h" +#include "llvm/Target/TargetSelect.h" #include using namespace llvm; @@ -229,8 +230,9 @@ return (void*)(intptr_t)gv.IntVal.getZExtValue(); } -int main() -{ +int main() { + InitializeNativeTarget(); + // Create some module to put our function into it. Module *M = new Module("test"); From clattner at apple.com Wed Jun 17 11:50:20 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Jun 2009 09:50:20 -0700 Subject: [llvm-commits] [llvm] r73595 - /llvm/trunk/tools/lli/lli.cpp In-Reply-To: <4A38C27E.5070505@gmail.com> References: <200906170215.n5H2FgjM019106@zion.cs.uiuc.edu> <4A38C27E.5070505@gmail.com> Message-ID: On Jun 17, 2009, at 3:16 AM, T?r?k Edwin wrote: > On 2009-06-17 05:15, Chris Lattner wrote: >> Author: lattner >> Date: Tue Jun 16 21:15:40 2009 >> New Revision: 73595 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=73595&view=rev >> Log: >> Use Doug's new LLVM_NATIVE_ARCH macro in config.h to link in the >> native >> target so that the JIT works in LLI, not just the interpreter. >> > > Hi Chris, > > Is this something that every JIT client should do? > examples/BrainF segfaults, because it finds no JITs for the target. Fixed, please verify. -Chris From edwintorok at gmail.com Wed Jun 17 11:55:43 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 17 Jun 2009 19:55:43 +0300 Subject: [llvm-commits] [llvm] r73595 - /llvm/trunk/tools/lli/lli.cpp In-Reply-To: References: <200906170215.n5H2FgjM019106@zion.cs.uiuc.edu> <4A38C27E.5070505@gmail.com> Message-ID: <4A39200F.7080604@gmail.com> On 2009-06-17 19:50, Chris Lattner wrote: > On Jun 17, 2009, at 3:16 AM, T?r?k Edwin wrote: > > >> On 2009-06-17 05:15, Chris Lattner wrote: >> >>> Author: lattner >>> Date: Tue Jun 16 21:15:40 2009 >>> New Revision: 73595 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=73595&view=rev >>> Log: >>> Use Doug's new LLVM_NATIVE_ARCH macro in config.h to link in the >>> native >>> target so that the JIT works in LLI, not just the interpreter. >>> >>> >> Hi Chris, >> >> Is this something that every JIT client should do? >> examples/BrainF segfaults, because it finds no JITs for the target. >> > > > Fixed, please verify. > Thanks, the JIT examples no longer segfault now. BrainF -jit works too (sort of, it an assertion failure): ------- Running JIT ------- Hello World! While deleting: i32 (i32)* %putchar An asserting value handle still pointed to this value! Aborted I'll open a bugreport for this, it is not related to the .o -> .a change. Best regards, --Edwin From resistor at mac.com Wed Jun 17 11:56:30 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 16:56:30 -0000 Subject: [llvm-commits] [llvm] r73614 - /llvm/trunk/lib/VMCore/TypeSymbolTable.cpp Message-ID: <200906171656.n5HGuVvq027692@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 11:56:27 2009 New Revision: 73614 URL: http://llvm.org/viewvc/llvm-project?rev=73614&view=rev Log: Type safety for TypeSymbolTable! Modified: llvm/trunk/lib/VMCore/TypeSymbolTable.cpp Modified: llvm/trunk/lib/VMCore/TypeSymbolTable.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/TypeSymbolTable.cpp?rev=73614&r1=73613&r2=73614&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/TypeSymbolTable.cpp (original) +++ llvm/trunk/lib/VMCore/TypeSymbolTable.cpp Wed Jun 17 11:56:27 2009 @@ -14,13 +14,18 @@ #include "llvm/TypeSymbolTable.h" #include "llvm/DerivedTypes.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Streams.h" +#include "llvm/Support/Threading.h" +#include "llvm/System/RWMutex.h" #include using namespace llvm; #define DEBUG_SYMBOL_TABLE 0 #define DEBUG_ABSTYPE 0 +static ManagedStatic TypeSymbolTableLock; + TypeSymbolTable::~TypeSymbolTable() { // Drop all abstract type references in the type plane... for (iterator TI = tmap.begin(), TE = tmap.end(); TI != TE; ++TI) { @@ -31,26 +36,39 @@ std::string TypeSymbolTable::getUniqueName(const std::string &BaseName) const { std::string TryName = BaseName; + + if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_acquire(); + const_iterator End = tmap.end(); // See if the name exists while (tmap.find(TryName) != End) // Loop until we find a free TryName = BaseName + utostr(++LastUnique); // name in the symbol table + + if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_release(); + return TryName; } // lookup a type by name - returns null on failure Type* TypeSymbolTable::lookup(const std::string& Name) const { + if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_acquire(); + const_iterator TI = tmap.find(Name); + Type* result = 0; if (TI != tmap.end()) - return const_cast(TI->second); - return 0; + result = const_cast(TI->second); + + if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_release(); + + return result; } // remove - Remove a type from the symbol table... Type* TypeSymbolTable::remove(iterator Entry) { + if (llvm_is_multithreaded()) TypeSymbolTableLock->writer_acquire(); + assert(Entry != tmap.end() && "Invalid entry to remove!"); - const Type* Result = Entry->second; #if DEBUG_SYMBOL_TABLE @@ -59,6 +77,8 @@ #endif tmap.erase(Entry); + + if (llvm_is_multithreaded()) TypeSymbolTableLock->writer_release(); // If we are removing an abstract type, remove the symbol table from it's use // list... @@ -79,6 +99,8 @@ void TypeSymbolTable::insert(const std::string& Name, const Type* T) { assert(T && "Can't insert null type into symbol table!"); + if (llvm_is_multithreaded()) TypeSymbolTableLock->writer_acquire(); + if (tmap.insert(make_pair(Name, T)).second) { // Type inserted fine with no conflict. @@ -103,6 +125,8 @@ // Insert the tmap entry tmap.insert(make_pair(UniqueName, T)); } + + if (llvm_is_multithreaded()) TypeSymbolTableLock->writer_release(); // If we are adding an abstract type, add the symbol table to it's use list. if (T->isAbstract()) { @@ -116,6 +140,7 @@ // This function is called when one of the types in the type plane are refined void TypeSymbolTable::refineAbstractType(const DerivedType *OldType, const Type *NewType) { + if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_acquire(); // Loop over all of the types in the symbol table, replacing any references // to OldType with references to NewType. Note that there may be multiple @@ -138,6 +163,8 @@ } } } + + if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_release(); } @@ -146,9 +173,11 @@ // Loop over all of the types in the symbol table, dropping any abstract // type user entries for AbsTy which occur because there are names for the // type. + if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_acquire(); for (iterator TI = begin(), TE = end(); TI != TE; ++TI) if (TI->second == const_cast(static_cast(AbsTy))) AbsTy->removeAbstractTypeUser(this); + if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_release(); } static void DumpTypes(const std::pair& T ) { @@ -159,7 +188,9 @@ void TypeSymbolTable::dump() const { cerr << "TypeSymbolPlane: "; + if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_acquire(); for_each(tmap.begin(), tmap.end(), DumpTypes); + if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_release(); } // vim: sw=2 ai From dgregor at apple.com Wed Jun 17 12:01:30 2009 From: dgregor at apple.com (Douglas Gregor) Date: Wed, 17 Jun 2009 17:01:30 -0000 Subject: [llvm-commits] [llvm] r73615 - /llvm/trunk/lib/System/CMakeLists.txt Message-ID: <200906171701.n5HH1UNS027911@zion.cs.uiuc.edu> Author: dgregor Date: Wed Jun 17 12:01:30 2009 New Revision: 73615 URL: http://llvm.org/viewvc/llvm-project?rev=73615&view=rev Log: Add RWMutex.cpp to the CMake makefiles Modified: llvm/trunk/lib/System/CMakeLists.txt Modified: llvm/trunk/lib/System/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/CMakeLists.txt?rev=73615&r1=73614&r2=73615&view=diff ============================================================================== --- llvm/trunk/lib/System/CMakeLists.txt (original) +++ llvm/trunk/lib/System/CMakeLists.txt Wed Jun 17 12:01:30 2009 @@ -10,6 +10,7 @@ Path.cpp Process.cpp Program.cpp + RWMutex.cpp Signals.cpp TimeValue.cpp ) From dgregor at apple.com Wed Jun 17 12:01:56 2009 From: dgregor at apple.com (Douglas Gregor) Date: Wed, 17 Jun 2009 17:01:56 -0000 Subject: [llvm-commits] [llvm] r73616 - in /llvm/trunk: cmake/config-ix.cmake include/llvm/Config/config.h.cmake Message-ID: <200906171701.n5HH1vsE027935@zion.cs.uiuc.edu> Author: dgregor Date: Wed Jun 17 12:01:56 2009 New Revision: 73616 URL: http://llvm.org/viewvc/llvm-project?rev=73616&view=rev Log: Define LLVM_NATIVE_ARCH in CMake, so that lli can actually JIT Modified: llvm/trunk/cmake/config-ix.cmake llvm/trunk/include/llvm/Config/config.h.cmake Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=73616&r1=73615&r2=73616&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Wed Jun 17 12:01:56 2009 @@ -78,6 +78,50 @@ get_target_triple(LLVM_HOSTTRIPLE) message(STATUS "LLVM_HOSTTRIPLE: ${LLVM_HOSTTRIPLE}") +# Determine the native architecture. +# FIXME: this will have to change for cross-compiling. +string(REGEX MATCH "^[^-]*" LLVM_NATIVE_ARCH ${LLVM_HOSTTRIPLE}) +if (LLVM_NATIVE_ARCH MATCHES "i[2-6]86") + set(LLVM_NATIVE_ARCH X86) +elseif (LLVM_NATIVE_ARCH STREQUAL amd64) + set(LLVM_NATIVE_ARCH X86) +elseif (LLVM_NATIVE_ARCH STREQUAL x86_64) + set(LLVM_NATIVE_ARCH X86) +elseif (LLVM_NATIVE_ARCH MATCHES "sparc") + set(LLVM_NATIVE_ARCH Sparc) +elseif (LLVM_NATIVE_ARCH MATCHES "powerpc") + set(LLVM_NATIVE_ARCH PowerPC) +elseif (LLVM_NATIVE_ARCH MATCHES "alpha") + set(LLVM_NATIVE_ARCH Alpha) +elseif (LLVM_NATIVE_ARCH MATCHES "ia64") + set(LLVM_NATIVE_ARCH IA64) +elseif (LLVM_NATIVE_ARCH MATCHES "arm") + set(LLVM_NATIVE_ARCH ARM) +elseif (LLVM_NATIVE_ARCH MATCHES "mips") + set(LLVM_NATIVE_ARCH Mips) +elseif (LLVM_NATIVE_ARCH MATCHES "pic16") + set(LLVM_NATIVE_ARCH "PIC16") +elseif (LLVM_NATIVE_ARCH MATCHES "xcore") + set(LLVM_NATIVE_ARCH XCore) +elseif (LLVM_NATIVE_ARCH MATCHES "msp430") + set(LLVM_NATIVE_ARCH MSP430) +else () + message(STATUS + "Unknown architecture ${LLVM_NATIVE_ARCH}; lli will not JIT code") + set(LLVM_NATIVE_ARCH) +endif () + +if (LLVM_NATIVE_ARCH) + list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX) + if (NATIVE_ARCH_IDX EQUAL -1) + message(STATUS + "Native target ${LLVM_NATIVE_ARCH} is not selected; lli will not JIT code") + set(LLVM_NATIVE_ARCH) + else () + message(STATUS "Native target architecture is ${LLVM_NATIVE_ARCH}") + endif () +endif() + if( MINGW ) set(HAVE_LIBIMAGEHLP 1) set(HAVE_LIBPSAPI 1) 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=73616&r1=73615&r2=73616&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.cmake (original) +++ llvm/trunk/include/llvm/Config/config.h.cmake Wed Jun 17 12:01:56 2009 @@ -580,3 +580,6 @@ /* Define to a function implementing strdup */ #cmakedefine strdup ${strdup} + +/* Native LLVM architecture */ +#cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH} From xerxes at zafena.se Wed Jun 17 05:52:12 2009 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Wed, 17 Jun 2009 12:52:12 +0200 Subject: [llvm-commits] [patch] RFC: BrainF -jit fix Message-ID: <4A38CADC.4040408@zafena.se> This patch makes the BrainF -jit work once again, the fix are similar to Chris r73595 change for lli. BrainF -jit /home/xerxes/hello.bf ------- Running JIT ------- Hello World! instead of BrainF -jit /home/xerxes/hello.bf ------- Running JIT ------- Segmentation fault Cheers Xerxes -------------- next part -------------- A non-text attachment was scrubbed... Name: BrainF_jit.patch Type: text/x-patch Size: 1419 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/5b89693a/attachment.bin From st at invia.fr Wed Jun 17 07:24:40 2009 From: st at invia.fr (Sylvere Teissier) Date: Wed, 17 Jun 2009 14:24:40 +0200 Subject: [llvm-commits] [llvm] r73579 - in /llvm/trunk: Makefile.rules docs/MakefileGuide.html tools/llvmc/driver/Makefile In-Reply-To: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> References: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> Message-ID: <1245241480.6797.15.camel@vostro-1510.invia> Le mardi 16 juin 2009 ? 23:00 +0000, Chris Lattner a ?crit : > Author: lattner > Date: Tue Jun 16 18:00:42 2009 > New Revision: 73579 > > URL: http://llvm.org/viewvc/llvm-project?rev=73579&view=rev > Log: > Remove support for building LLVM libraries into "relinked" > object files. Now we always build LLVM libraries into archives (.a files). > > This makes the 'make' build work more like the cmake build, among other > things. Doing this exposed some latent circular library dependencies, so > I think that llvm-config wasn't quite right for .o files anyway. > > > Modified: > llvm/trunk/Makefile.rules > llvm/trunk/docs/MakefileGuide.html > llvm/trunk/tools/llvmc/driver/Makefile > > Modified: llvm/trunk/Makefile.rules > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=73579&r1=73578&r2=73579&view=diff Hi, you have modified llvmc/driver/Makefile but you forgot to modify llvmc/examples/*/driver/Makefile From xerxes at zafena.se Wed Jun 17 07:49:19 2009 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Wed, 17 Jun 2009 14:49:19 +0200 Subject: [llvm-commits] [patch] RFC: BrainF -jit fix In-Reply-To: <4A38CADC.4040408@zafena.se> References: <4A38CADC.4040408@zafena.se> Message-ID: <4A38E64F.6000104@zafena.se> Xerxes R?nby skrev: > This patch makes the BrainF -jit work once again, the fix are similar > to Chris r73595 change for lli. > > BrainF -jit /home/xerxes/hello.bf > ------- Running JIT ------- > Hello World! > > instead of > > BrainF -jit /home/xerxes/hello.bf > ------- Running JIT ------- > Segmentation fault > > Cheers > Xerxes Rather than having to rely on using a macro to create InitializeX86Target() i would have been happy to use InitializeAllTargets() like this: Index: llvm/examples/BrainF/BrainFDriver.cpp =================================================================== --- llvm.orig/examples/BrainF/BrainFDriver.cpp 2009-06-17 12:20:14.000000000 +0200 +++ llvm/examples/BrainF/BrainFDriver.cpp 2009-06-17 14:36:00.000000000 +0200 @@ -34,6 +34,7 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/InitializeAllTargets.h" #include #include using namespace llvm; @@ -133,6 +134,9 @@ abort(); } + // If we have a native target, initialize it to ensure it is linked in. + InitializeAllTargets(); + //Write it out if (JIT) { std::cout << "------- Running JIT -------\n"; ================================================ snap Yet llvm/InitializeAllTargets.h semms unusable for this purpose, it simple spits out: llvm[0]: Linking Debug executable BrainF /home/xerxes/llvm/examples/BrainF/Debug/BrainFDriver.o: In function `InitializeAllTargets': /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeCppBackendTarget()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeMSILTarget()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeCBackendTarget()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeMSP430Target()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeXCoreTarget()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializePIC16Target()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeCellSPUTarget()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeMipsTarget()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeARMTarget()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeIA64Target()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeAlphaTarget()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializePowerPCTarget()' /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined reference to `llvm::InitializeSparcTarget()' during linking. Anyone know a better way to initialize the JIT without having to rely on arch dependent code? Cheers Xerxes From st at invia.fr Wed Jun 17 08:54:36 2009 From: st at invia.fr (Sylvere Teissier) Date: Wed, 17 Jun 2009 15:54:36 +0200 Subject: [llvm-commits] [llvm] r73579 - in /llvm/trunk: Makefile.rules docs/MakefileGuide.html tools/llvmc/driver/Makefile In-Reply-To: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> References: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> Message-ID: <1245246876.6797.19.camel@vostro-1510.invia> Le mardi 16 juin 2009 ? 23:00 +0000, Chris Lattner a ?crit : > Author: lattner > Date: Tue Jun 16 18:00:42 2009 > New Revision: 73579 > > URL: http://llvm.org/viewvc/llvm-project?rev=73579&view=rev > Log: > Remove support for building LLVM libraries into "relinked" > object files. Now we always build LLVM libraries into archives (.a files). > > This makes the 'make' build work more like the cmake build, among other > things. Doing this exposed some latent circular library dependencies, so > I think that llvm-config wasn't quite right for .o files anyway. Furthermore, llvmc seems to be broken in my config. It doesn't contains clang and base plugins, or is it intentional ? From resistor at mac.com Wed Jun 17 12:13:58 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 17:13:58 -0000 Subject: [llvm-commits] [llvm] r73617 - /llvm/trunk/lib/VMCore/Type.cpp Message-ID: <200906171713.n5HHDxtn028405@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 12:13:54 2009 New Revision: 73617 URL: http://llvm.org/viewvc/llvm-project?rev=73617&view=rev Log: We need to guard reads of the AbstractTypeUsers list, as well as writes to it. While it would be nice to use a R/W lock here, we can't, because it HAS to be recursive. Modified: llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73617&r1=73616&r2=73617&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Wed Jun 17 12:13:54 2009 @@ -46,7 +46,7 @@ // Reader/writer lock used for guarding access to the type maps. static ManagedStatic TypeMapLock; -// Lock used for guarding access to AbstractTypeUsers. +// Recursive lock used for guarding access to AbstractTypeUsers. static ManagedStatic AbstractTypeUsersLock; // Concrete/Abstract TypeDescriptions - We lazily calculate type descriptions @@ -1544,6 +1544,7 @@ // will not cause users to drop off of the use list. If we resolve to ourself // we succeed! // + if (llvm_is_multithreaded()) AbstractTypeUsersLock->acquire(); while (!AbstractTypeUsers.empty() && NewTy != this) { AbstractTypeUser *User = AbstractTypeUsers.back(); @@ -1559,6 +1560,7 @@ assert(AbstractTypeUsers.size() != OldSize && "AbsTyUser did not remove self from user list!"); } + if (llvm_is_multithreaded()) AbstractTypeUsersLock->release(); // If we were successful removing all users from the type, 'this' will be // deleted when the last PATypeHolder is destroyed or updated from this type. @@ -1589,6 +1591,7 @@ DOUT << "typeIsREFINED type: " << (void*)this << " " << *this << "\n"; #endif + if (llvm_is_multithreaded()) AbstractTypeUsersLock->acquire(); unsigned OldSize = AbstractTypeUsers.size(); OldSize=OldSize; while (!AbstractTypeUsers.empty()) { AbstractTypeUser *ATU = AbstractTypeUsers.back(); @@ -1597,6 +1600,7 @@ assert(AbstractTypeUsers.size() < OldSize-- && "AbstractTypeUser did not remove itself from the use list!"); } + if (llvm_is_multithreaded()) AbstractTypeUsersLock->release(); } // refineAbstractType - Called when a contained type is found to be more From resistor at mac.com Wed Jun 17 12:37:03 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 17:37:03 -0000 Subject: [llvm-commits] [llvm] r73620 - /llvm/trunk/lib/VMCore/Value.cpp Message-ID: <200906171737.n5HHb4TU029232@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 12:36:57 2009 New Revision: 73620 URL: http://llvm.org/viewvc/llvm-project?rev=73620&view=rev Log: Protect the ValueHandle table. Modified: llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=73620&r1=73619&r2=73620&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Wed Jun 17 12:36:57 2009 @@ -21,7 +21,9 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/Threading.h" #include "llvm/Support/ValueHandle.h" +#include "llvm/System/RWMutex.h" #include "llvm/ADT/DenseMap.h" #include using namespace llvm; @@ -405,6 +407,7 @@ /// not a value has an entry in this map. typedef DenseMap ValueHandlesTy; static ManagedStatic ValueHandles; +static ManagedStatic ValueHandlesLock; /// AddToExistingUseList - Add this ValueHandle to the use list for VP, where /// List is known to point into the existing use list. @@ -427,9 +430,12 @@ if (VP->HasValueHandle) { // If this value already has a ValueHandle, then it must be in the // ValueHandles map already. + if (llvm_is_multithreaded()) ValueHandlesLock->reader_acquire(); ValueHandleBase *&Entry = (*ValueHandles)[VP]; assert(Entry != 0 && "Value doesn't have any handles?"); - return AddToExistingUseList(&Entry); + AddToExistingUseList(&Entry); + if (llvm_is_multithreaded()) ValueHandlesLock->reader_release(); + return; } // Ok, it doesn't have any handles yet, so we must insert it into the @@ -437,6 +443,7 @@ // reallocate itself, which would invalidate all of the PrevP pointers that // point into the old table. Handle this by checking for reallocation and // updating the stale pointers only if needed. + if (llvm_is_multithreaded()) ValueHandlesLock->writer_acquire(); ValueHandlesTy &Handles = *ValueHandles; const void *OldBucketPtr = Handles.getPointerIntoBucketsArray(); @@ -448,8 +455,10 @@ // If reallocation didn't happen or if this was the first insertion, don't // walk the table. if (Handles.isPointerIntoBucketsArray(OldBucketPtr) || - Handles.size() == 1) + Handles.size() == 1) { + if (llvm_is_multithreaded()) ValueHandlesLock->writer_release(); return; + } // Okay, reallocation did happen. Fix the Prev Pointers. for (ValueHandlesTy::iterator I = Handles.begin(), E = Handles.end(); @@ -457,6 +466,8 @@ assert(I->second && I->first == I->second->VP && "List invariant broken!"); I->second->setPrevPtr(&I->second); } + + if (llvm_is_multithreaded()) ValueHandlesLock->writer_release(); } /// RemoveFromUseList - Remove this ValueHandle from its current use list. @@ -477,11 +488,13 @@ // If the Next pointer was null, then it is possible that this was the last // ValueHandle watching VP. If so, delete its entry from the ValueHandles // map. + if (llvm_is_multithreaded()) ValueHandlesLock->writer_acquire(); ValueHandlesTy &Handles = *ValueHandles; if (Handles.isPointerIntoBucketsArray(PrevPtr)) { Handles.erase(VP); VP->HasValueHandle = false; } + if (llvm_is_multithreaded()) ValueHandlesLock->writer_release(); } @@ -490,7 +503,9 @@ // Get the linked list base, which is guaranteed to exist since the // HasValueHandle flag is set. + if (llvm_is_multithreaded()) ValueHandlesLock->reader_acquire(); ValueHandleBase *Entry = (*ValueHandles)[V]; + if (llvm_is_multithreaded()) ValueHandlesLock->reader_release(); assert(Entry && "Value bit set but no entries exist"); while (Entry) { @@ -528,7 +543,9 @@ // Get the linked list base, which is guaranteed to exist since the // HasValueHandle flag is set. + if (llvm_is_multithreaded()) ValueHandlesLock->reader_acquire(); ValueHandleBase *Entry = (*ValueHandles)[Old]; + if (llvm_is_multithreaded()) ValueHandlesLock->reader_release(); assert(Entry && "Value bit set but no entries exist"); while (Entry) { From gohman at apple.com Wed Jun 17 12:51:36 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Jun 2009 17:51:36 -0000 Subject: [llvm-commits] [llvm] r73621 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200906171751.n5HHpaqJ029833@zion.cs.uiuc.edu> Author: djg Date: Wed Jun 17 12:51:33 2009 New Revision: 73621 URL: http://llvm.org/viewvc/llvm-project?rev=73621&view=rev Log: Update comments to use doxygen syntax. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=73621&r1=73620&r2=73621&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Wed Jun 17 12:51:33 2009 @@ -1129,11 +1129,11 @@ return SC->getValue()->getValue().isNegative(); } -// CollectIVUsers - Transform our list of users and offsets to a bit more -// complex table. In this new vector, each 'BasedUser' contains 'Base', the base -// of the strided accesses, as well as the old information from Uses. We -// progressively move information from the Base field to the Imm field, until -// we eventually have the full access expression to rewrite the use. +/// CollectIVUsers - Transform our list of users and offsets to a bit more +/// complex table. In this new vector, each 'BasedUser' contains 'Base', the base +/// of the strided accesses, as well as the old information from Uses. We +/// progressively move information from the Base field to the Imm field, until +/// we eventually have the full access expression to rewrite the use. SCEVHandle LoopStrengthReduce::CollectIVUsers(const SCEVHandle &Stride, IVUsersOfOneStride &Uses, Loop *L, @@ -2284,9 +2284,9 @@ } } -// OptimizeIndvars - Now that IVUsesByStride is set up with all of the indvar -// uses in the loop, look to see if we can eliminate some, in favor of using -// common indvars for the different uses. +/// OptimizeIndvars - Now that IVUsesByStride is set up with all of the indvar +/// uses in the loop, look to see if we can eliminate some, in favor of using +/// common indvars for the different uses. void LoopStrengthReduce::OptimizeIndvars(Loop *L) { // TODO: implement optzns here. @@ -2413,9 +2413,9 @@ ++NumLoopCond; } -// OptimizeLoopCountIV - If, after all sharing of IVs, the IV used for deciding -// when to exit the loop is used only for that purpose, try to rearrange things -// so it counts down to a test against zero. +/// OptimizeLoopCountIV - If, after all sharing of IVs, the IV used for deciding +/// when to exit the loop is used only for that purpose, try to rearrange things +/// so it counts down to a test against zero. void LoopStrengthReduce::OptimizeLoopCountIV(Loop *L) { // If the number of times the loop is executed isn't computable, give up. From asl at math.spbu.ru Wed Jun 17 13:13:59 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Wed, 17 Jun 2009 18:13:59 -0000 Subject: [llvm-commits] [llvm] r73622 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/thumb2-add.ll test/CodeGen/ARM/thumb2-mov.ll test/CodeGen/ARM/thumb2-mov2.ll test/CodeGen/ARM/thumb2-shifter.ll Message-ID: <200906171814.n5HIE08Q030499@zion.cs.uiuc.edu> Author: asl Date: Wed Jun 17 13:13:58 2009 New Revision: 73622 URL: http://llvm.org/viewvc/llvm-project?rev=73622&view=rev Log: Initial support for some Thumb2 instructions. Patch by Viktor Kutuzov and Anton Korzh from Access Softek, Inc. Added: llvm/trunk/test/CodeGen/ARM/thumb2-add.ll llvm/trunk/test/CodeGen/ARM/thumb2-mov.ll llvm/trunk/test/CodeGen/ARM/thumb2-mov2.ll llvm/trunk/test/CodeGen/ARM/thumb2-shifter.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=73622&r1=73621&r2=73622&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Jun 17 13:13:58 2009 @@ -52,8 +52,13 @@ virtual const char *getPassName() const { return "ARM Instruction Selection"; - } - + } + + /// getI32Imm - Return a target constant with the specified value, of type i32. + inline SDValue getI32Imm(unsigned Imm) { + return CurDAG->getTargetConstant(Imm, MVT::i32); + } + SDNode *Select(SDValue Op); virtual void InstructionSelect(); bool SelectAddrMode2(SDValue Op, SDValue N, SDValue &Base, @@ -84,6 +89,9 @@ bool SelectThumbAddrModeSP(SDValue Op, SDValue N, SDValue &Base, SDValue &OffImm); + bool SelectShifterOperand(SDValue Op, SDValue N, + SDValue &BaseReg, SDValue &Opc); + bool SelectShifterOperandReg(SDValue Op, SDValue N, SDValue &A, SDValue &B, SDValue &C); @@ -509,8 +517,30 @@ return false; } +bool ARMDAGToDAGISel::SelectShifterOperand(SDValue Op, + SDValue N, + SDValue &BaseReg, + SDValue &Opc) { + ARM_AM::ShiftOpc ShOpcVal = ARM_AM::getShiftOpcForNode(N); + + // Don't match base register only case. That is matched to a separate + // lower complexity pattern with explicit register operand. + if (ShOpcVal == ARM_AM::no_shift) return false; + + BaseReg = N.getOperand(0); + unsigned ShImmVal = 0; + if (ConstantSDNode *RHS = dyn_cast(N.getOperand(1))) + ShImmVal = RHS->getZExtValue() & 31; + else + return false; + + Opc = getI32Imm(ARM_AM::getSORegOpc(ShOpcVal, ShImmVal)); + + return true; +} + bool ARMDAGToDAGISel::SelectShifterOperandReg(SDValue Op, - SDValue N, + SDValue N, SDValue &BaseReg, SDValue &ShReg, SDValue &Opc) { @@ -549,6 +579,10 @@ switch (N->getOpcode()) { default: break; case ISD::Constant: { + // ARMv6T2 and later should materialize imms via MOV / MOVT pair. + if (Subtarget->hasV6T2Ops() || Subtarget->hasThumb2()) + break; + unsigned Val = cast(N)->getZExtValue(); bool UseCP = true; if (Subtarget->isThumb()) Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=73622&r1=73621&r2=73622&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Jun 17 13:13:58 2009 @@ -1385,6 +1385,12 @@ include "ARMInstrThumb.td" //===----------------------------------------------------------------------===// +// Thumb2 Support +// + +include "ARMInstrThumb2.td" + +//===----------------------------------------------------------------------===// // Floating Point Support // Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=73622&r1=73621&r2=73622&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Wed Jun 17 13:13:58 2009 @@ -10,3 +10,199 @@ // This file describes the Thumb2 instruction set. // //===----------------------------------------------------------------------===// + +// Shifted operands. No register controlled shifts for Thumb2. +// Note: We do not support rrx shifted operands yet. +def t2_so_reg : Operand, // reg imm + ComplexPattern { + let PrintMethod = "printSOOperand"; + let MIOperandInfo = (ops GPR, i32imm); +} + +def LO16 : SDNodeXFormgetZExtValue()); +}]>; + +def HI16 : SDNodeXFormgetZExtValue() >> 16); +}]>; + +def imm16high : PatLeaf<(i32 imm), [{ + // Returns true if all bits out of the [31..16] range are 0. + return ((N->getZExtValue() & 0xFFFF0000ULL) == N->getZExtValue()); +}], HI16>; + +def imm16high0xffff : PatLeaf<(i32 imm), [{ + // Returns true if lo 16 bits are set and this is a 32-bit value. + return ((N->getZExtValue() & 0x0000FFFFULL) == 0xFFFFULL); +}], HI16>; + +def imm0_4095 : PatLeaf<(i32 imm), [{ + return (uint32_t)N->getZExtValue() < 4096; +}]>; + +def imm0_4095_neg : PatLeaf<(i32 imm), [{ + return (uint32_t)-N->getZExtValue() < 4096; +}], imm_neg_XFORM>; + +def imm0_65535 : PatLeaf<(i32 imm), [{ + return N->getZExtValue() < 65536; +}]>; + +// A6.3.2 Modified immediate constants in Thumb instructions (#) +// FIXME: Move it the the addrmode matcher code. +def t2_so_imm : PatLeaf<(i32 imm), [{ + uint64_t v = N->getZExtValue(); + if (v == 0 || v > 0xffffffffUL) return false; + // variant1 - 0b0000x - 8-bit which could be zero (not supported for now) + + // variant2 - 0b00nnx - 8-bit repeated inside the 32-bit room + unsigned hi16 = (unsigned)(v >> 16); + unsigned lo16 = (unsigned)(v & 0xffffUL); + bool valid = (hi16 == lo16) && ( + (v & 0x00ff00ffUL) == 0 || // type 0001x + (v & 0xff00ff00UL) == 0 || // type 0010x + ((lo16 >> 8) == (lo16 & 0xff))); // type 0011x + if (valid) return true; + + // variant3 - 0b01000..0b11111 - 8-bit shifted inside the 32-bit room + unsigned shift = CountLeadingZeros_32(v); + uint64_t mask = (0xff000000ULL >> shift); + // If valid, it is type 01000 + shift + return ((shift < 24) && (v & mask) > 0) && ((v & (~mask)) == 0); +}]>; + + +//===----------------------------------------------------------------------===// +// Thumb-2 to cover the functionality of the ARM instruction set. +// + +/// T2I_bin_irs - Defines a set of (op reg, {so_imm|reg|so_reg}) patterns for a +// binary operation that produces a value. +multiclass T2I_bin_irs { + // shifted imm + def ri : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs), + !strconcat(opc, " $dst, $lhs, $rhs"), + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]>, + Requires<[HasThumb2]>; + // register + def rr : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs), + !strconcat(opc, " $dst, $lhs, $rhs"), + [(set GPR:$dst, (opnode GPR:$lhs, GPR:$rhs))]>, + Requires<[HasThumb2]>; + // shifted register + def rs : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs), + !strconcat(opc, " $dst, $lhs, $rhs"), + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]>, + Requires<[HasThumb2]>; +} + +/// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' bit so the +/// instruction modifies the CPSR register. +let Defs = [CPSR] in { +multiclass T2I_bin_s_irs { + // shifted imm + def ri : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs), + !strconcat(opc, "s $dst, $lhs, $rhs"), + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]>, + Requires<[HasThumb2]>; + + // register + def rr : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs), + !strconcat(opc, "s $dst, $lhs, $rhs"), + [(set GPR:$dst, (opnode GPR:$lhs, GPR:$rhs))]>, + Requires<[HasThumb2]>; + + // shifted register + def rs : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs), + !strconcat(opc, "s $dst, $lhs, $rhs"), + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]>, + Requires<[HasThumb2]>; +} +} + +/// T2I_bin_c_irs - Similar to T2I_bin_irs except it uses the 's' bit. Also the +/// instruction can optionally set the CPSR register. +let Uses = [CPSR] in { +multiclass T2I_bin_c_irs { + // shifted imm + def ri : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs, cc_out:$s), + !strconcat(opc, "${s} $dst, $lhs, $rhs"), + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm:$rhs))]>, + Requires<[HasThumb2]>; + + // register + def rr : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs, cc_out:$s), + !strconcat(opc, "${s} $dst, $lhs, $rhs"), + [(set GPR:$dst, (opnode GPR:$lhs, GPR:$rhs))]>, + Requires<[HasThumb2]>; + + // shifted register + def rs : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg:$rhs, cc_out:$s), + !strconcat(opc, "${s} $dst, $lhs, $rhs"), + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg:$rhs))]>, + Requires<[HasThumb2]>; +} +} + +//===----------------------------------------------------------------------===// +// Arithmetic Instructions. +// + +//===----------------------------------------------------------------------===// +// Move Instructions. +// +def tMOVi16 : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), + "mov $dst, $src", + [(set GPR:$dst, imm0_65535:$src)]>, + Requires<[HasThumb2]>; + +let isTwoAddress = 1 in +def tMOVTi16 : PseudoInst<(outs GPR:$dst), (ins GPR:$src, i32imm:$imm), + "movt $dst, $imm", + [(set GPR:$dst, (or (and GPR:$src, 0xffff), + imm16high:$imm))]>, + Requires<[HasThumb2]>; + +def : Pat<(and (or GPR:$src, imm16high:$imm1), imm16high0xffff:$imm2), + (tMOVTi16 GPR:$src, (HI16 imm16high:$imm1))>, + Requires<[HasThumb2]>; + +def : Pat<(i32 imm:$imm), + (tMOVTi16 (tMOVi16 (LO16 imm:$imm)),(HI16 imm:$imm))>, + Requires<[HasThumb2]>; + +//===----------------------------------------------------------------------===// +// Arithmetic Instructions. +// +defm t2ADD : T2I_bin_irs <"add", BinOpFrag<(add node:$LHS, node:$RHS)>>; +defm t2SUB : T2I_bin_irs <"sub", BinOpFrag<(sub node:$LHS, node:$RHS)>>; + +def tADDri12 : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs), + "add $dst, $lhs, $rhs", + [(set GPR:$dst, (add GPR:$lhs, imm0_4095:$rhs))]>, + Requires<[HasThumb2]>; +def tSUBri12 : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs), + "sub $dst, $lhs, $rhs", + [(set GPR:$dst, (add GPR:$lhs, imm0_4095_neg:$rhs))]>, + Requires<[HasThumb2]>; + +defm t2ADDS : T2I_bin_s_irs<"add", BinOpFrag<(addc node:$LHS, node:$RHS)>>; +defm t2SUBS : T2I_bin_s_irs<"sub", BinOpFrag<(subc node:$LHS, node:$RHS)>>; + +defm t2ADC : T2I_bin_c_irs<"adc", BinOpFrag<(adde node:$LHS, node:$RHS)>>; +defm t2SBC : T2I_bin_c_irs<"sbc", BinOpFrag<(sube node:$LHS, node:$RHS)>>; + + +def tMLS : PseudoInst<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), + "mls $dst, $a, $b, $c", + [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>, + Requires<[HasThumb2]>; + +def tORNrs : PseudoInst<(outs GPR:$dst), (ins GPR:$src1, t2_so_reg:$src2), + "orn $dst, $src1, $src2", + [(set GPR:$dst, (or GPR:$src1, (not t2_so_reg: $src2)))]>, + Requires<[HasThumb2]>; Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=73622&r1=73621&r2=73622&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Jun 17 13:13:58 2009 @@ -97,6 +97,7 @@ const char *Modifier = 0); void printSOImmOperand(const MachineInstr *MI, int opNum); void printSOImm2PartOperand(const MachineInstr *MI, int opNum); + void printSOOperand(const MachineInstr *MI, int OpNum); void printSORegOperand(const MachineInstr *MI, int opNum); void printAddrMode2Operand(const MachineInstr *MI, int OpNo); void printAddrMode2OffsetOperand(const MachineInstr *MI, int OpNo); @@ -396,6 +397,28 @@ printSOImm(O, ARM_AM::getSOImmVal(V2), VerboseAsm, TAI); } +// Constant shifts so_reg is a 3-operand unit corresponding to register forms of +// the A5.1 "Addressing Mode 1 - Data-processing operands" forms. This +// includes: +// REG 0 - e.g. R5 +// REG IMM, SH_OPC - e.g. R5, LSL #3 +void ARMAsmPrinter::printSOOperand(const MachineInstr *MI, int OpNum) { + const MachineOperand &MO1 = MI->getOperand(OpNum); + const MachineOperand &MO2 = MI->getOperand(OpNum+1); + + unsigned Reg = MO1.getReg(); + assert(TargetRegisterInfo::isPhysicalRegister(Reg)); + O << TM.getRegisterInfo()->getAsmName(Reg); + + // Print the shift opc. + O << ", " + << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO2.getImm())) + << " "; + + assert(MO2.isImm() && "Not a valid t2_so_reg value!"); + O << "#" << ARM_AM::getSORegOffset(MO2.getImm()); +} + // so_reg is a 4-operand unit corresponding to register forms of the A5.1 // "Addressing Mode 1 - Data-processing operands" forms. This includes: // REG 0 0 - e.g. R5 Added: llvm/trunk/test/CodeGen/ARM/thumb2-add.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb2-add.ll?rev=73622&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/thumb2-add.ll (added) +++ llvm/trunk/test/CodeGen/ARM/thumb2-add.ll Wed Jun 17 13:13:58 2009 @@ -0,0 +1,50 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | grep #255 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | grep #256 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | grep #257 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | grep #4094 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | grep #4095 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | grep #4096 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | grep lsl | grep #8 + +define i32 @t2ADDrc_255(i32 %lhs) { + %Rd = add i32 %lhs, 255; + ret i32 %Rd +} + +define i32 @t2ADDrc_256(i32 %lhs) { + %Rd = add i32 %lhs, 256; + ret i32 %Rd +} + +define i32 @t2ADDrc_257(i32 %lhs) { + %Rd = add i32 %lhs, 257; + ret i32 %Rd +} + +define i32 @t2ADDrc_4094(i32 %lhs) { + %Rd = add i32 %lhs, 4094; + ret i32 %Rd +} + +define i32 @t2ADDrc_4095(i32 %lhs) { + %Rd = add i32 %lhs, 4095; + ret i32 %Rd +} + +define i32 @t2ADDrc_4096(i32 %lhs) { + %Rd = add i32 %lhs, 4096; + ret i32 %Rd +} + +define i32 @t2ADDrr(i32 %lhs, i32 %rhs) { + %Rd = add i32 %lhs, %rhs; + ret i32 %Rd +} + +define i32 @t2ADDrs(i32 %lhs, i32 %rhs) { + %tmp = shl i32 %rhs, 8 + %Rd = add i32 %lhs, %tmp; + ret i32 %Rd +} + Added: llvm/trunk/test/CodeGen/ARM/thumb2-mov.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb2-mov.ll?rev=73622&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/thumb2-mov.ll (added) +++ llvm/trunk/test/CodeGen/ARM/thumb2-mov.ll Wed Jun 17 13:13:58 2009 @@ -0,0 +1,127 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep #11206827 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep #2868947712 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep #2880154539 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep #251658240 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep #3948544 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep #258 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep #4026531840 + +; Test # + +; var 2.1 - 0x00ab00ab +define i32 @t2_const_var2_1_ok_1(i32 %lhs) { + %ret = add i32 %lhs, 11206827 ; 0x00ab00ab + ret i32 %ret +} + +define i32 @t2_const_var2_1_fail_1(i32 %lhs) { + %ret = add i32 %lhs, 11206843 ; 0x00ab00bb + ret i32 %ret +} + +define i32 @t2_const_var2_1_fail_2(i32 %lhs) { + %ret = add i32 %lhs, 27984043 ; 0x01ab00ab + ret i32 %ret +} + +define i32 @t2_const_var2_1_fail_3(i32 %lhs) { + %ret = add i32 %lhs, 27984299 ; 0x01ab01ab + ret i32 %ret +} + +define i32 @t2_const_var2_1_fail_4(i32 %lhs) { + %ret = add i32 %lhs, 28027649 ; 0x01abab01 + ret i32 %ret +} + +; var 2.2 - 0xab00ab00 +define i32 @t2_const_var2_2_ok_1(i32 %lhs) { + %ret = add i32 %lhs, 2868947712 ; 0xab00ab00 + ret i32 %ret +} + +define i32 @t2_const_var2_2_fail_1(i32 %lhs) { + %ret = add i32 %lhs, 2868951552 ; 0xab00ba00 + ret i32 %ret +} + +define i32 @t2_const_var2_2_fail_2(i32 %lhs) { + %ret = add i32 %lhs, 2868947728 ; 0xab00ab10 + ret i32 %ret +} + +define i32 @t2_const_var2_2_fail_3(i32 %lhs) { + %ret = add i32 %lhs, 2869996304 ; 0xab10ab10 + ret i32 %ret +} + +define i32 @t2_const_var2_2_fail_4(i32 %lhs) { + %ret = add i32 %lhs, 279685904 ; 0x10abab10 + ret i32 %ret +} + +; var 2.3 - 0xabababab +define i32 @t2_const_var2_3_ok_1(i32 %lhs) { + %ret = add i32 %lhs, 2880154539 ; 0xabababab + ret i32 %ret +} + +define i32 @t2_const_var2_3_fail_1(i32 %lhs) { + %ret = add i32 %lhs, 2880154554 ; 0xabababba + ret i32 %ret +} + +define i32 @t2_const_var2_3_fail_2(i32 %lhs) { + %ret = add i32 %lhs, 2880158379 ; 0xababbaab + ret i32 %ret +} + +define i32 @t2_const_var2_3_fail_3(i32 %lhs) { + %ret = add i32 %lhs, 2881137579 ; 0xabbaabab + ret i32 %ret +} + +define i32 @t2_const_var2_3_fail_4(i32 %lhs) { + %ret = add i32 %lhs, 3131812779 ; 0xbaababab + ret i32 %ret +} + +; var 3 - 0x0F000000 +define i32 @t2_const_var3_1_ok_1(i32 %lhs) { + %ret = add i32 %lhs, 251658240 ; 0x0F000000 + ret i32 %ret +} + +define i32 @t2_const_var3_2_ok_1(i32 %lhs) { + %ret = add i32 %lhs, 3948544 ; 0b00000000001111000100000000000000 + ret i32 %ret +} + +define i32 @t2_const_var3_2_fail_1(i32 %lhs) { + %ret = add i32 %lhs, 3940352 ; 0b00000000001111000010000000000000 + ret i32 %ret +} + +define i32 @t2_const_var3_3_ok_1(i32 %lhs) { + %ret = add i32 %lhs, 258 ; 0b00000000000000000000000100000010 + ret i32 %ret +} + +define i32 @t2_const_var3_4_ok_1(i32 %lhs) { + %ret = add i32 %lhs, 4026531840 ; 0xF0000000 + ret i32 %ret +} + Added: llvm/trunk/test/CodeGen/ARM/thumb2-mov2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb2-mov2.ll?rev=73622&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/thumb2-mov2.ll (added) +++ llvm/trunk/test/CodeGen/ARM/thumb2-mov2.ll Wed Jun 17 13:13:58 2009 @@ -0,0 +1,65 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movt | grep #1234 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movt | grep #1234 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movt | grep #1234 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movt | grep #1234 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | grep movt + +define i32 @t2MOVTi16_ok_1(i32 %a) { + %1 = and i32 %a, 65535 + %2 = shl i32 1234, 16 + %3 = or i32 %1, %2 + + ret i32 %3 +} + +define i32 @t2MOVTi16_test_1(i32 %a) { + %1 = shl i32 255, 8 + %2 = shl i32 1234, 8 + %3 = or i32 %1, 255 ; This give us 0xFFFF in %3 + %4 = shl i32 %2, 8 ; This gives us (1234 << 16) in %4 + %5 = and i32 %a, %3 + %6 = or i32 %4, %5 + + ret i32 %6 +} + +define i32 @t2MOVTi16_test_2(i32 %a) { + %1 = shl i32 255, 8 + %2 = shl i32 1234, 8 + %3 = or i32 %1, 255 ; This give us 0xFFFF in %3 + %4 = shl i32 %2, 6 + %5 = and i32 %a, %3 + %6 = shl i32 %4, 2 ; This gives us (1234 << 16) in %6 + %7 = or i32 %5, %6 + + ret i32 %7 +} + +define i32 @t2MOVTi16_test_3(i32 %a) { + %1 = shl i32 255, 8 + %2 = shl i32 1234, 8 + %3 = or i32 %1, 255 ; This give us 0xFFFF in %3 + %4 = shl i32 %2, 6 + %5 = and i32 %a, %3 + %6 = shl i32 %4, 2 ; This gives us (1234 << 16) in %6 + %7 = lshr i32 %6, 6 + %8 = shl i32 %7, 6 + %9 = or i32 %5, %8 + + ret i32 %9 +} + +define i32 @t2MOVTi16_test_nomatch_1(i32 %a) { + %1 = shl i32 255, 8 + %2 = shl i32 1234, 8 + %3 = or i32 %1, 255 ; This give us 0xFFFF in %3 + %4 = shl i32 %2, 6 + %5 = and i32 %a, %3 + %6 = shl i32 %4, 2 ; This gives us (1234 << 16) in %6 + %7 = lshr i32 %6, 3 + %8 = or i32 %5, %7 + + ret i32 %8 +} + + Added: llvm/trunk/test/CodeGen/ARM/thumb2-shifter.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb2-shifter.ll?rev=73622&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/thumb2-shifter.ll (added) +++ llvm/trunk/test/CodeGen/ARM/thumb2-shifter.ll Wed Jun 17 13:13:58 2009 @@ -0,0 +1,40 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep lsl +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep lsr +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep asr +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep ror +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov + +define i32 @t2ADDrs_lsl(i32 %X, i32 %Y) { + %A = shl i32 %Y, 16 + %B = add i32 %X, %A + ret i32 %B +} + +define i32 @t2ADDrs_lsr(i32 %X, i32 %Y) { + %A = lshr i32 %Y, 16 + %B = add i32 %X, %A + ret i32 %B +} + +define i32 @t2ADDrs_asr(i32 %X, i32 %Y) { + %A = ashr i32 %Y, 16 + %B = add i32 %X, %A + ret i32 %B +} + +; i32 ror(n) = (x >> n) | (x << (32 - n)) +define i32 @t2ADDrs_ror(i32 %X, i32 %Y) { + %A = lshr i32 %Y, 16 + %B = shl i32 %Y, 16 + %C = or i32 %B, %A + %R = add i32 %X, %C + ret i32 %R +} + +define i32 @t2ADDrs_noRegShift(i32 %X, i32 %Y, i8 %sh) { + %shift.upgrd.1 = zext i8 %sh to i32 + %A = shl i32 %Y, %shift.upgrd.1 + %B = add i32 %X, %A + ret i32 %B +} + From isanbard at gmail.com Wed Jun 17 13:23:17 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 17 Jun 2009 11:23:17 -0700 Subject: [llvm-commits] [llvm] r73590 - /llvm/trunk/autoconf/configure.ac In-Reply-To: <200906170042.n5H0gXIU015833@zion.cs.uiuc.edu> References: <200906170042.n5H0gXIU015833@zion.cs.uiuc.edu> Message-ID: <16e5fdf90906171123i469fcfb5s1a64e1b9355d9f00@mail.gmail.com> Did you regenerate the configure file? :-) -bw On Tue, Jun 16, 2009 at 5:42 PM, Douglas Gregor wrote: > Author: dgregor > Date: Tue Jun 16 19:42:33 2009 > New Revision: 73590 > > URL: http://llvm.org/viewvc/llvm-project?rev=73590&view=rev > Log: > Define LLVM_NATIVE_ARCH in llvm/Config/config.h to be the LLVM back end that corresponds to the native executable, but only when that LLVM back end is being built > > Modified: > ? ?llvm/trunk/autoconf/configure.ac > > Modified: llvm/trunk/autoconf/configure.ac > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=73590&r1=73589&r2=73590&view=diff > > ============================================================================== > --- llvm/trunk/autoconf/configure.ac (original) > +++ llvm/trunk/autoconf/configure.ac Tue Jun 16 19:42:33 2009 > @@ -234,6 +234,13 @@ > ? AC_MSG_WARN([Configuring LLVM for an unknown target archicture]) > ?fi > > +# Determine the LLVM native architecture for the target > +case "$llvm_cv_target_arch" in > + ? ?x86) ? ? LLVM_NATIVE_ARCH="X86" ;; > + ? ?x86_64) ?LLVM_NATIVE_ARCH="X86" ;; > + ? ?*) ? ? ? LLVM_NATIVE_ARCH="$llvm_cv_target_arch" ;; > +esac > + > ?dnl Define a substitution, ARCH, for the target architecture > ?AC_SUBST(ARCH,$llvm_cv_target_arch) > > @@ -436,6 +443,15 @@ > ?esac > ?AC_SUBST(TARGETS_TO_BUILD,$TARGETS_TO_BUILD) > > +# Determine whether we are building LLVM support for the native architecture. > +# If so, define LLVM_NATIVE_ARCH to that LLVM target. > +for a_target in $TARGETS_TO_BUILD; do > + ?if test "$a_target" = "$LLVM_NATIVE_ARCH"; then > + ? ?AC_DEFINE_UNQUOTED(LLVM_NATIVE_ARCH,$LLVM_NATIVE_ARCH, > + ? ? ?[LLVM architecture name for the native architecture, if available]) > + ?fi > +done > + > ?# Build the LLVM_TARGET and LLVM_ASM_PRINTER macro uses for > ?# Targets.def and AsmPrinters.def. > ?LLVM_ENUM_TARGETS="" > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From isanbard at gmail.com Wed Jun 17 13:23:40 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 17 Jun 2009 11:23:40 -0700 Subject: [llvm-commits] [llvm] r73591 - in /llvm/trunk: configure include/llvm/Config/config.h.in In-Reply-To: <200906170043.n5H0hL6M015898@zion.cs.uiuc.edu> References: <200906170043.n5H0hL6M015898@zion.cs.uiuc.edu> Message-ID: <16e5fdf90906171123h325bf3edhc8ffe23ad1be3b0b@mail.gmail.com> Oops! Never mind my previous email. -bw On Tue, Jun 16, 2009 at 5:43 PM, Douglas Gregor wrote: > Author: dgregor > Date: Tue Jun 16 19:43:20 2009 > New Revision: 73591 > > URL: http://llvm.org/viewvc/llvm-project?rev=73591&view=rev > Log: > Update auto-generated configuration files > > Modified: > ? ?llvm/trunk/configure > ? ?llvm/trunk/include/llvm/Config/config.h.in > > Modified: llvm/trunk/configure > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=73591&r1=73590&r2=73591&view=diff > > ============================================================================== > --- llvm/trunk/configure (original) > +++ llvm/trunk/configure Tue Jun 16 19:43:20 2009 > @@ -2403,6 +2403,13 @@ > ?echo "$as_me: WARNING: Configuring LLVM for an unknown target archicture" >&2;} > ?fi > > +# Determine the LLVM native architecture for the target > +case "$llvm_cv_target_arch" in > + ? ?x86) ? ? LLVM_NATIVE_ARCH="X86" ;; > + ? ?x86_64) ?LLVM_NATIVE_ARCH="X86" ;; > + ? ?*) ? ? ? LLVM_NATIVE_ARCH="$llvm_cv_target_arch" ;; > +esac > + > ?ARCH=$llvm_cv_target_arch > > > @@ -4961,6 +4968,18 @@ > ?TARGETS_TO_BUILD=$TARGETS_TO_BUILD > > > +# Determine whether we are building LLVM support for the native architecture. > +# If so, define LLVM_NATIVE_ARCH to that LLVM target. > +for a_target in $TARGETS_TO_BUILD; do > + ?if test "$a_target" = "$LLVM_NATIVE_ARCH"; then > + > +cat >>confdefs.h <<_ACEOF > +#define LLVM_NATIVE_ARCH $LLVM_NATIVE_ARCH > +_ACEOF > + > + ?fi > +done > + > ?# Build the LLVM_TARGET and LLVM_ASM_PRINTER macro uses for > ?# Targets.def and AsmPrinters.def. > ?LLVM_ENUM_TARGETS="" > @@ -10609,7 +10628,7 @@ > ? lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > ? lt_status=$lt_dlunknown > ? cat > conftest.$ac_ext < -#line 10612 "configure" > +#line 10631 "configure" > ?#include "confdefs.h" > > ?#if HAVE_DLFCN_H > @@ -12753,7 +12772,7 @@ > ? ;; > ?*-*-irix6*) > ? # Find out which ABI we are using. > - ?echo '#line 12756 "configure"' > conftest.$ac_ext > + ?echo '#line 12775 "configure"' > conftest.$ac_ext > ? if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 > ? (eval $ac_compile) 2>&5 > ? ac_status=$? > @@ -14471,11 +14490,11 @@ > ? ?-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ > ? ?-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ > ? ?-e 's:$: $lt_compiler_flag:'` > - ? (eval echo "\"\$as_me:14474: $lt_compile\"" >&5) > + ? (eval echo "\"\$as_me:14493: $lt_compile\"" >&5) > ? ?(eval "$lt_compile" 2>conftest.err) > ? ?ac_status=$? > ? ?cat conftest.err >&5 > - ? echo "$as_me:14478: \$? = $ac_status" >&5 > + ? echo "$as_me:14497: \$? = $ac_status" >&5 > ? ?if (exit $ac_status) && test -s "$ac_outfile"; then > ? ? ?# The compiler can only warn and ignore the option if not recognized > ? ? ?# So say no if there are warnings other than the usual output. > @@ -14739,11 +14758,11 @@ > ? ?-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ > ? ?-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ > ? ?-e 's:$: $lt_compiler_flag:'` > - ? (eval echo "\"\$as_me:14742: $lt_compile\"" >&5) > + ? (eval echo "\"\$as_me:14761: $lt_compile\"" >&5) > ? ?(eval "$lt_compile" 2>conftest.err) > ? ?ac_status=$? > ? ?cat conftest.err >&5 > - ? echo "$as_me:14746: \$? = $ac_status" >&5 > + ? echo "$as_me:14765: \$? = $ac_status" >&5 > ? ?if (exit $ac_status) && test -s "$ac_outfile"; then > ? ? ?# The compiler can only warn and ignore the option if not recognized > ? ? ?# So say no if there are warnings other than the usual output. > @@ -14843,11 +14862,11 @@ > ? ?-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ > ? ?-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ > ? ?-e 's:$: $lt_compiler_flag:'` > - ? (eval echo "\"\$as_me:14846: $lt_compile\"" >&5) > + ? (eval echo "\"\$as_me:14865: $lt_compile\"" >&5) > ? ?(eval "$lt_compile" 2>out/conftest.err) > ? ?ac_status=$? > ? ?cat out/conftest.err >&5 > - ? echo "$as_me:14850: \$? = $ac_status" >&5 > + ? echo "$as_me:14869: \$? = $ac_status" >&5 > ? ?if (exit $ac_status) && test -s out/conftest2.$ac_objext > ? ?then > ? ? ?# The compiler can only warn and ignore the option if not recognized > @@ -17295,7 +17314,7 @@ > ? lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > ? lt_status=$lt_dlunknown > ? cat > conftest.$ac_ext < -#line 17298 "configure" > +#line 17317 "configure" > ?#include "confdefs.h" > > ?#if HAVE_DLFCN_H > @@ -17395,7 +17414,7 @@ > ? lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > ? lt_status=$lt_dlunknown > ? cat > conftest.$ac_ext < -#line 17398 "configure" > +#line 17417 "configure" > ?#include "confdefs.h" > > ?#if HAVE_DLFCN_H > @@ -19763,11 +19782,11 @@ > ? ?-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ > ? ?-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ > ? ?-e 's:$: $lt_compiler_flag:'` > - ? (eval echo "\"\$as_me:19766: $lt_compile\"" >&5) > + ? (eval echo "\"\$as_me:19785: $lt_compile\"" >&5) > ? ?(eval "$lt_compile" 2>conftest.err) > ? ?ac_status=$? > ? ?cat conftest.err >&5 > - ? echo "$as_me:19770: \$? = $ac_status" >&5 > + ? echo "$as_me:19789: \$? = $ac_status" >&5 > ? ?if (exit $ac_status) && test -s "$ac_outfile"; then > ? ? ?# The compiler can only warn and ignore the option if not recognized > ? ? ?# So say no if there are warnings other than the usual output. > @@ -19867,11 +19886,11 @@ > ? ?-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ > ? ?-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ > ? ?-e 's:$: $lt_compiler_flag:'` > - ? (eval echo "\"\$as_me:19870: $lt_compile\"" >&5) > + ? (eval echo "\"\$as_me:19889: $lt_compile\"" >&5) > ? ?(eval "$lt_compile" 2>out/conftest.err) > ? ?ac_status=$? > ? ?cat out/conftest.err >&5 > - ? echo "$as_me:19874: \$? = $ac_status" >&5 > + ? echo "$as_me:19893: \$? = $ac_status" >&5 > ? ?if (exit $ac_status) && test -s out/conftest2.$ac_objext > ? ?then > ? ? ?# The compiler can only warn and ignore the option if not recognized > @@ -21437,11 +21456,11 @@ > ? ?-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ > ? ?-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ > ? ?-e 's:$: $lt_compiler_flag:'` > - ? (eval echo "\"\$as_me:21440: $lt_compile\"" >&5) > + ? (eval echo "\"\$as_me:21459: $lt_compile\"" >&5) > ? ?(eval "$lt_compile" 2>conftest.err) > ? ?ac_status=$? > ? ?cat conftest.err >&5 > - ? echo "$as_me:21444: \$? = $ac_status" >&5 > + ? echo "$as_me:21463: \$? = $ac_status" >&5 > ? ?if (exit $ac_status) && test -s "$ac_outfile"; then > ? ? ?# The compiler can only warn and ignore the option if not recognized > ? ? ?# So say no if there are warnings other than the usual output. > @@ -21541,11 +21560,11 @@ > ? ?-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ > ? ?-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ > ? ?-e 's:$: $lt_compiler_flag:'` > - ? (eval echo "\"\$as_me:21544: $lt_compile\"" >&5) > + ? (eval echo "\"\$as_me:21563: $lt_compile\"" >&5) > ? ?(eval "$lt_compile" 2>out/conftest.err) > ? ?ac_status=$? > ? ?cat out/conftest.err >&5 > - ? echo "$as_me:21548: \$? = $ac_status" >&5 > + ? echo "$as_me:21567: \$? = $ac_status" >&5 > ? ?if (exit $ac_status) && test -s out/conftest2.$ac_objext > ? ?then > ? ? ?# The compiler can only warn and ignore the option if not recognized > @@ -23776,11 +23795,11 @@ > ? ?-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ > ? ?-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ > ? ?-e 's:$: $lt_compiler_flag:'` > - ? (eval echo "\"\$as_me:23779: $lt_compile\"" >&5) > + ? (eval echo "\"\$as_me:23798: $lt_compile\"" >&5) > ? ?(eval "$lt_compile" 2>conftest.err) > ? ?ac_status=$? > ? ?cat conftest.err >&5 > - ? echo "$as_me:23783: \$? = $ac_status" >&5 > + ? echo "$as_me:23802: \$? = $ac_status" >&5 > ? ?if (exit $ac_status) && test -s "$ac_outfile"; then > ? ? ?# The compiler can only warn and ignore the option if not recognized > ? ? ?# So say no if there are warnings other than the usual output. > @@ -24044,11 +24063,11 @@ > ? ?-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ > ? ?-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ > ? ?-e 's:$: $lt_compiler_flag:'` > - ? (eval echo "\"\$as_me:24047: $lt_compile\"" >&5) > + ? (eval echo "\"\$as_me:24066: $lt_compile\"" >&5) > ? ?(eval "$lt_compile" 2>conftest.err) > ? ?ac_status=$? > ? ?cat conftest.err >&5 > - ? echo "$as_me:24051: \$? = $ac_status" >&5 > + ? echo "$as_me:24070: \$? = $ac_status" >&5 > ? ?if (exit $ac_status) && test -s "$ac_outfile"; then > ? ? ?# The compiler can only warn and ignore the option if not recognized > ? ? ?# So say no if there are warnings other than the usual output. > @@ -24148,11 +24167,11 @@ > ? ?-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ > ? ?-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ > ? ?-e 's:$: $lt_compiler_flag:'` > - ? (eval echo "\"\$as_me:24151: $lt_compile\"" >&5) > + ? (eval echo "\"\$as_me:24170: $lt_compile\"" >&5) > ? ?(eval "$lt_compile" 2>out/conftest.err) > ? ?ac_status=$? > ? ?cat out/conftest.err >&5 > - ? echo "$as_me:24155: \$? = $ac_status" >&5 > + ? echo "$as_me:24174: \$? = $ac_status" >&5 > ? ?if (exit $ac_status) && test -s out/conftest2.$ac_objext > ? ?then > ? ? ?# The compiler can only warn and ignore the option if not recognized > > 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=73591&r1=73590&r2=73591&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Config/config.h.in (original) > +++ llvm/trunk/include/llvm/Config/config.h.in Tue Jun 16 19:43:20 2009 > @@ -476,6 +476,9 @@ > ?/* Build multithreading support into LLVM */ > ?#undef LLVM_MULTITHREADED > > +/* LLVM architecture name for the native architecture, if available */ > +#undef LLVM_NATIVE_ARCH > + > ?/* Define if this is Unixish platform */ > ?#undef LLVM_ON_UNIX > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From edwintorok at gmail.com Wed Jun 17 13:35:49 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 17 Jun 2009 21:35:49 +0300 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) Message-ID: <4A393785.8090202@gmail.com> Hi, I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't folded, the attached patch folds this into: umax (zext t1 %X to %t0, zext t1 %Y to %t0). It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext t1 (umax (%X, %Y)) to %t0. zext is very often encountered in SCEV expressions on x86-64, since pointer indexes for GEP are i64. Thoughts? Best regards, --Edwin -------------- next part -------------- A non-text attachment was scrubbed... Name: scev.patch Type: text/x-diff Size: 1980 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/b4449434/attachment.bin From resistor at mac.com Wed Jun 17 13:40:33 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 18:40:33 -0000 Subject: [llvm-commits] [llvm] r73624 - /llvm/trunk/lib/VMCore/Constants.cpp Message-ID: <200906171840.n5HIeZtO031368@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 13:40:29 2009 New Revision: 73624 URL: http://llvm.org/viewvc/llvm-project?rev=73624&view=rev Log: Type safety for Constants.cpp! Some of this is temporary, as I'm planning to push some of the R/W locking into FoldingSet. Modified: llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73624&r1=73623&r2=73624&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Wed Jun 17 13:40:29 2009 @@ -25,6 +25,8 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/Threading.h" +#include "llvm/System/RWMutex.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include @@ -35,6 +37,8 @@ // Constant Class //===----------------------------------------------------------------------===// +ManagedStatic ConstantsLock; + void Constant::destroyConstantImpl() { // When a Constant is destroyed, there may be lingering // references to the constant by other constants in the constant pool. These @@ -295,12 +299,30 @@ const IntegerType *ITy = IntegerType::get(V.getBitWidth()); // get an existing value or the insertion position DenseMapAPIntKeyInfo::KeyTy Key(V, ITy); - ConstantInt *&Slot = (*IntConstants)[Key]; - // if it exists, return it. - if (Slot) + + if (llvm_is_multithreaded()) { + ConstantsLock->reader_acquire(); + ConstantInt *&Slot = (*IntConstants)[Key]; + ConstantsLock->reader_release(); + + if (!Slot) { + ConstantsLock->writer_acquire(); + ConstantInt *&Slot = (*IntConstants)[Key]; + if (!Slot) { + Slot = new ConstantInt(ITy, V); + } + ConstantsLock->writer_release(); + } + return Slot; - // otherwise create a new one, insert it, and return it. - return Slot = new ConstantInt(ITy, V); + } else { + ConstantInt *&Slot = (*IntConstants)[Key]; + // if it exists, return it. + if (Slot) + return Slot; + // otherwise create a new one, insert it, and return it. + return Slot = new ConstantInt(ITy, V); + } } Constant *ConstantInt::get(const Type *Ty, const APInt &V) { @@ -392,24 +414,58 @@ ConstantFP *ConstantFP::get(const APFloat &V) { DenseMapAPFloatKeyInfo::KeyTy Key(V); - ConstantFP *&Slot = (*FPConstants)[Key]; - if (Slot) return Slot; - const Type *Ty; - if (&V.getSemantics() == &APFloat::IEEEsingle) - Ty = Type::FloatTy; - else if (&V.getSemantics() == &APFloat::IEEEdouble) - Ty = Type::DoubleTy; - else if (&V.getSemantics() == &APFloat::x87DoubleExtended) - Ty = Type::X86_FP80Ty; - else if (&V.getSemantics() == &APFloat::IEEEquad) - Ty = Type::FP128Ty; - else { - assert(&V.getSemantics() == &APFloat::PPCDoubleDouble&&"Unknown FP format"); - Ty = Type::PPC_FP128Ty; + if (llvm_is_multithreaded()) { + ConstantsLock->reader_acquire(); + ConstantFP *&Slot = (*FPConstants)[Key]; + ConstantsLock->reader_release(); + + if (!Slot) { + ConstantsLock->writer_acquire(); + Slot = (*FPConstants)[Key]; + if (!Slot) { + const Type *Ty; + if (&V.getSemantics() == &APFloat::IEEEsingle) + Ty = Type::FloatTy; + else if (&V.getSemantics() == &APFloat::IEEEdouble) + Ty = Type::DoubleTy; + else if (&V.getSemantics() == &APFloat::x87DoubleExtended) + Ty = Type::X86_FP80Ty; + else if (&V.getSemantics() == &APFloat::IEEEquad) + Ty = Type::FP128Ty; + else { + assert(&V.getSemantics() == &APFloat::PPCDoubleDouble && + "Unknown FP format"); + Ty = Type::PPC_FP128Ty; + } + + Slot = new ConstantFP(Ty, V); + } + ConstantsLock->writer_release(); + } + + return Slot; + } else { + ConstantFP *&Slot = (*FPConstants)[Key]; + if (Slot) return Slot; + + const Type *Ty; + if (&V.getSemantics() == &APFloat::IEEEsingle) + Ty = Type::FloatTy; + else if (&V.getSemantics() == &APFloat::IEEEdouble) + Ty = Type::DoubleTy; + else if (&V.getSemantics() == &APFloat::x87DoubleExtended) + Ty = Type::X86_FP80Ty; + else if (&V.getSemantics() == &APFloat::IEEEquad) + Ty = Type::FP128Ty; + else { + assert(&V.getSemantics() == &APFloat::PPCDoubleDouble && + "Unknown FP format"); + Ty = Type::PPC_FP128Ty; + } + + return Slot = new ConstantFP(Ty, V); } - - return Slot = new ConstantFP(Ty, V); } /// get() - This returns a constant fp for the specified value in the @@ -1346,13 +1402,19 @@ ConstantAggregateZero *ConstantAggregateZero::get(const Type *Ty) { assert((isa(Ty) || isa(Ty) || isa(Ty)) && "Cannot create an aggregate zero of non-aggregate type!"); - return AggZeroConstants->getOrCreate(Ty, 0); + ConstantAggregateZero* result = 0; + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + result = AggZeroConstants->getOrCreate(Ty, 0); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } /// destroyConstant - Remove the constant from the constant table... /// void ConstantAggregateZero::destroyConstant() { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); AggZeroConstants->remove(this); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -1389,21 +1451,30 @@ Constant *ConstantArray::get(const ArrayType *Ty, const std::vector &V) { // If this is an all-zero array, return a ConstantAggregateZero object + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); if (!V.empty()) { Constant *C = V[0]; - if (!C->isNullValue()) + if (!C->isNullValue()) { + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); return ArrayConstants->getOrCreate(Ty, V); + } for (unsigned i = 1, e = V.size(); i != e; ++i) - if (V[i] != C) + if (V[i] != C) { + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); return ArrayConstants->getOrCreate(Ty, V); + } } + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return ConstantAggregateZero::get(Ty); } /// destroyConstant - Remove the constant from the constant table... /// void ConstantArray::destroyConstant() { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); ArrayConstants->remove(this); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -1512,9 +1583,14 @@ Constant *ConstantStruct::get(const StructType *Ty, const std::vector &V) { // Create a ConstantAggregateZero value if all elements are zeros... + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); for (unsigned i = 0, e = V.size(); i != e; ++i) - if (!V[i]->isNullValue()) - return StructConstants->getOrCreate(Ty, V); + if (!V[i]->isNullValue()) { + Constant* result = StructConstants->getOrCreate(Ty, V); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; + } + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); return ConstantAggregateZero::get(Ty); } @@ -1530,7 +1606,9 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantStruct::destroyConstant() { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); StructConstants->remove(this); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); destroyConstantImpl(); } @@ -1584,7 +1662,10 @@ return ConstantAggregateZero::get(Ty); if (isUndef) return UndefValue::get(Ty); - return VectorConstants->getOrCreate(Ty, V); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = VectorConstants->getOrCreate(Ty, V); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant *ConstantVector::get(const std::vector &V) { @@ -1595,7 +1676,9 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantVector::destroyConstant() { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); VectorConstants->remove(this); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -1659,13 +1742,18 @@ ConstantPointerNull *ConstantPointerNull::get(const PointerType *Ty) { - return NullPtrConstants->getOrCreate(Ty, 0); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + ConstantPointerNull* result = NullPtrConstants->getOrCreate(Ty, 0); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } // destroyConstant - Remove the constant from the constant table... // void ConstantPointerNull::destroyConstant() { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); NullPtrConstants->remove(this); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -1702,13 +1790,18 @@ UndefValue *UndefValue::get(const Type *Ty) { - return UndefValueConstants->getOrCreate(Ty, 0); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + UndefValue* result = UndefValueConstants->getOrCreate(Ty, 0); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } // destroyConstant - Remove the constant from the constant table. // void UndefValue::destroyConstant() { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); UndefValueConstants->remove(this); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -1722,16 +1815,21 @@ static ManagedStatic > MDStringCache; MDString *MDString::get(const char *StrBegin, const char *StrEnd) { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); StringMapEntry &Entry = MDStringCache->GetOrCreateValue(StrBegin, StrEnd); MDString *&S = Entry.getValue(); if (!S) S = new MDString(Entry.getKeyData(), Entry.getKeyData() + Entry.getKeyLength()); + + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); return S; } void MDString::destroyConstant() { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd)); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -1756,18 +1854,40 @@ for (unsigned i = 0; i != NumVals; ++i) ID.AddPointer(Vals[i]); - void *InsertPoint; - if (MDNode *N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint)) + if (llvm_is_multithreaded()) { + ConstantsLock->reader_acquire(); + void *InsertPoint; + MDNode *N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); + ConstantsLock->reader_release(); + + if (!N) { + ConstantsLock->writer_acquire(); + N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); + if (!N) { + // InsertPoint will have been set by the FindNodeOrInsertPos call. + MDNode *N = new(0) MDNode(Vals, NumVals); + MDNodeSet->InsertNode(N, InsertPoint); + } + ConstantsLock->writer_release(); + } + return N; - - // InsertPoint will have been set by the FindNodeOrInsertPos call. - MDNode *N = new(0) MDNode(Vals, NumVals); - MDNodeSet->InsertNode(N, InsertPoint); - return N; + } else { + void *InsertPoint; + if (MDNode *N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint)) + return N; + + // InsertPoint will have been set by the FindNodeOrInsertPos call. + MDNode *N = new(0) MDNode(Vals, NumVals); + MDNodeSet->InsertNode(N, InsertPoint); + return N; + } } void MDNode::destroyConstant() { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); MDNodeSet->RemoveNode(this); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -1934,7 +2054,11 @@ // Look up the constant in the table first to ensure uniqueness std::vector argVec(1, C); ExprMapKeyType Key(opc, argVec); - return ExprConstants->getOrCreate(Ty, Key); + + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = ExprConstants->getOrCreate(Ty, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty) { @@ -2194,7 +2318,10 @@ std::vector argVec(1, C1); argVec.push_back(C2); ExprMapKeyType Key(Opcode, argVec); - return ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant *ConstantExpr::getCompareTy(unsigned short predicate, @@ -2305,7 +2432,10 @@ argVec[1] = V1; argVec[2] = V2; ExprMapKeyType Key(Instruction::Select, argVec); - return ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant *ConstantExpr::getGetElementPtrTy(const Type *ReqTy, Constant *C, @@ -2328,7 +2458,10 @@ for (unsigned i = 0; i != NumIdx; ++i) ArgVec.push_back(cast(Idxs[i])); const ExprMapKeyType Key(Instruction::GetElementPtr, ArgVec); - return ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant *result = ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant *ConstantExpr::getGetElementPtr(Constant *C, Value* const *Idxs, @@ -2362,7 +2495,10 @@ ArgVec.push_back(RHS); // Get the key type with both the opcode and predicate const ExprMapKeyType Key(Instruction::ICmp, ArgVec, pred); - return ExprConstants->getOrCreate(Type::Int1Ty, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = ExprConstants->getOrCreate(Type::Int1Ty, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant * @@ -2379,7 +2515,10 @@ ArgVec.push_back(RHS); // Get the key type with both the opcode and predicate const ExprMapKeyType Key(Instruction::FCmp, ArgVec, pred); - return ExprConstants->getOrCreate(Type::Int1Ty, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = ExprConstants->getOrCreate(Type::Int1Ty, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant * @@ -2424,7 +2563,10 @@ ArgVec.push_back(RHS); // Get the key type with both the opcode and predicate const ExprMapKeyType Key(Instruction::VICmp, ArgVec, pred); - return ExprConstants->getOrCreate(LHS->getType(), Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = ExprConstants->getOrCreate(LHS->getType(), Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant * @@ -2471,7 +2613,10 @@ ArgVec.push_back(RHS); // Get the key type with both the opcode and predicate const ExprMapKeyType Key(Instruction::VFCmp, ArgVec, pred); - return ExprConstants->getOrCreate(ResultTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = ExprConstants->getOrCreate(ResultTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant *ConstantExpr::getExtractElementTy(const Type *ReqTy, Constant *Val, @@ -2482,7 +2627,10 @@ std::vector ArgVec(1, Val); ArgVec.push_back(Idx); const ExprMapKeyType Key(Instruction::ExtractElement,ArgVec); - return ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant *ConstantExpr::getExtractElement(Constant *Val, Constant *Idx) { @@ -2503,7 +2651,10 @@ ArgVec.push_back(Elt); ArgVec.push_back(Idx); const ExprMapKeyType Key(Instruction::InsertElement,ArgVec); - return ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant *ConstantExpr::getInsertElement(Constant *Val, Constant *Elt, @@ -2526,7 +2677,10 @@ ArgVec.push_back(V2); ArgVec.push_back(Mask); const ExprMapKeyType Key(Instruction::ShuffleVector,ArgVec); - return ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + Constant* result = ExprConstants->getOrCreate(ReqTy, Key); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + return result; } Constant *ConstantExpr::getShuffleVector(Constant *V1, Constant *V2, @@ -2609,7 +2763,9 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantExpr::destroyConstant() { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); ExprConstants->remove(this); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -2673,6 +2829,7 @@ Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); bool Exists; ArrayConstantsTy::MapTy::iterator I = ArrayConstants->InsertOrGetItem(Lookup, Exists); @@ -2698,8 +2855,10 @@ if (getOperand(i) == From) setOperand(i, ToC); } + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); return; } + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); } // Otherwise, I do need to replace this with an existing value. @@ -2748,6 +2907,7 @@ Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); bool Exists; StructConstantsTy::MapTy::iterator I = StructConstants->InsertOrGetItem(Lookup, Exists); @@ -2763,8 +2923,10 @@ // Update to the new value. setOperand(OperandToUpdate, ToC); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); return; } + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); } assert(Replacement != this && "I didn't contain From!"); From edwintorok at gmail.com Wed Jun 17 13:46:23 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 17 Jun 2009 21:46:23 +0300 Subject: [llvm-commits] [PATCH] Attempt to DSE non-local stores Message-ID: <4A3939FF.30404@gmail.com> Hi, I realised that DSE wasn't actually deleting stores that were really dead (no loads/stores from pointer), but only deleted redundant stores ( when there was a second load/store from same pointer). DeadStoreElimination also has a comment :// FIXME: cross-block DSE would be fun. :) The attached patch is a small, incremental improvement: - it handles single non-local dependencies the same as local deps - it handles the case where an instruction only has a fake dep (first inst in BB) On the attached bitcode DSE is able to eliminate 3 stores, that LLVM is currently not eliminating at -O3. Before thinking about more complex non-local DSE, I am sending out this patch for review. In particular can I rely on MemDep returning a single fake dependency when there are no instructions accessing that pointer (or alias thereof) in the entire function? Would it make sense to improve MemDep to return 2 new kind of dependencies: - nonFunctionLocal: there is no instruction/call in the current function that can possibly access the pointer (or alias thereof), except the instruction being queried - Dead/None: as nonFunctionLocal, but removing the instruction being queried doesn't change the behaviour of the function, i.e. the pointer doesn't alias any of the function's arguments, or globals Best regards, --Edwin -------------- next part -------------- A non-text attachment was scrubbed... Name: dse.patch Type: text/x-diff Size: 2428 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/b700456f/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: x.bc Type: application/octet-stream Size: 3272 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/b700456f/attachment.obj From clattner at apple.com Wed Jun 17 13:46:53 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Jun 2009 11:46:53 -0700 Subject: [llvm-commits] [patch] RFC: BrainF -jit fix In-Reply-To: <4A38E64F.6000104@zafena.se> References: <4A38CADC.4040408@zafena.se> <4A38E64F.6000104@zafena.se> Message-ID: <50C88CBF-F9DD-4F95-A3F5-EFA4FEA8B9D5@apple.com> Hi Xerxes, I'm sorry I didn't see this email, this should be fixed on mainline. -Chris On Jun 17, 2009, at 5:49 AM, Xerxes R?nby wrote: > Xerxes R?nby skrev: >> This patch makes the BrainF -jit work once again, the fix are similar >> to Chris r73595 change for lli. >> >> BrainF -jit /home/xerxes/hello.bf >> ------- Running JIT ------- >> Hello World! >> >> instead of >> >> BrainF -jit /home/xerxes/hello.bf >> ------- Running JIT ------- >> Segmentation fault >> >> Cheers >> Xerxes > > Rather than having to rely on using a macro to create > InitializeX86Target() i would have been happy to use > InitializeAllTargets() like this: > > Index: llvm/examples/BrainF/BrainFDriver.cpp > =================================================================== > --- llvm.orig/examples/BrainF/BrainFDriver.cpp 2009-06-17 > 12:20:14.000000000 +0200 > +++ llvm/examples/BrainF/BrainFDriver.cpp 2009-06-17 > 14:36:00.000000000 +0200 > @@ -34,6 +34,7 @@ > #include "llvm/ExecutionEngine/JIT.h" > #include "llvm/Support/CommandLine.h" > #include "llvm/Support/ManagedStatic.h" > +#include "llvm/InitializeAllTargets.h" > #include > #include > using namespace llvm; > @@ -133,6 +134,9 @@ > abort(); > } > > + // If we have a native target, initialize it to ensure it is > linked in. > + InitializeAllTargets(); > + > //Write it out > if (JIT) { > std::cout << "------- Running JIT -------\n"; > > ================================================ snap > > Yet llvm/InitializeAllTargets.h semms unusable for this purpose, it > simple spits out: > > llvm[0]: Linking Debug executable BrainF > /home/xerxes/llvm/examples/BrainF/Debug/BrainFDriver.o: In function > `InitializeAllTargets': > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeCppBackendTarget()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeMSILTarget()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeCBackendTarget()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeMSP430Target()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeXCoreTarget()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializePIC16Target()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeCellSPUTarget()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeMipsTarget()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeARMTarget()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeIA64Target()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeAlphaTarget()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializePowerPCTarget()' > /home/xerxes/llvm/include/llvm/Config/Targets.def:26: undefined > reference to `llvm::InitializeSparcTarget()' > > during linking. > > Anyone know a better way to initialize the JIT without having to > rely on > arch dependent code? > > Cheers > Xerxes > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Wed Jun 17 13:47:36 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Jun 2009 11:47:36 -0700 Subject: [llvm-commits] [llvm] r73579 - in /llvm/trunk: Makefile.rules docs/MakefileGuide.html tools/llvmc/driver/Makefile In-Reply-To: <1245241480.6797.15.camel@vostro-1510.invia> References: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> <1245241480.6797.15.camel@vostro-1510.invia> Message-ID: <82A8DBE4-C17E-4DDB-8431-B4E91F75AAAA@apple.com> On Jun 17, 2009, at 5:24 AM, Sylvere Teissier wrote: >> >> Modified: >> llvm/trunk/Makefile.rules >> llvm/trunk/docs/MakefileGuide.html >> llvm/trunk/tools/llvmc/driver/Makefile >> >> Modified: llvm/trunk/Makefile.rules >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=73579&r1=73578&r2=73579&view=diff > > Hi, you have modified llvmc/driver/Makefile but you forgot to modify > llvmc/examples/*/driver/Makefile What change is needed? I'm not familiar with llvmc, what isn't working? -Chris From edwintorok at gmail.com Wed Jun 17 13:48:18 2009 From: edwintorok at gmail.com (Torok Edwin) Date: Wed, 17 Jun 2009 18:48:18 -0000 Subject: [llvm-commits] [llvm] r73625 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp Message-ID: <200906171848.n5HImIDk031655@zion.cs.uiuc.edu> Author: edwin Date: Wed Jun 17 13:48:18 2009 New Revision: 73625 URL: http://llvm.org/viewvc/llvm-project?rev=73625&view=rev Log: Add debug message about non-local loads being clobbered. 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=73625&r1=73624&r2=73625&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Jun 17 13:48:18 2009 @@ -952,8 +952,14 @@ // 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].second.isClobber()) + if (Deps.size() == 1 && Deps[0].second.isClobber()) { + DEBUG( + DOUT << "GVN: non-local load "; + WriteAsOperand(*DOUT.stream(), LI); + DOUT << " is clobbered by " << *Deps[0].second.getInst(); + ); return false; + } // Filter out useless results (non-locals, etc). Keep track of the blocks // where we have a value available in repl, also keep track of whether we see From clattner at apple.com Wed Jun 17 13:49:34 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Jun 2009 11:49:34 -0700 Subject: [llvm-commits] [llvm] r73620 - /llvm/trunk/lib/VMCore/Value.cpp In-Reply-To: <200906171737.n5HHb4TU029232@zion.cs.uiuc.edu> References: <200906171737.n5HHb4TU029232@zion.cs.uiuc.edu> Message-ID: On Jun 17, 2009, at 10:37 AM, Owen Anderson wrote: > Author: resistor > Date: Wed Jun 17 12:36:57 2009 > New Revision: 73620 > > URL: http://llvm.org/viewvc/llvm-project?rev=73620&view=rev > Log: > Protect the ValueHandle table. Owen, can you please add an RAII object to handle the locking and unlocking? Instead of: > > // Get the linked list base, which is guaranteed to exist since the > // HasValueHandle flag is set. > + if (llvm_is_multithreaded()) ValueHandlesLock->reader_acquire(); > ValueHandleBase *Entry = (*ValueHandles)[V]; > + if (llvm_is_multithreaded()) ValueHandlesLock->reader_release(); > assert(Entry && "Value bit set but no entries exist"); it would be very nice to have: { RWReaderLocker X(*ValueHandlesLock); Entry = (*ValueHandles)[V]; } ... -Chris From nlewycky at google.com Wed Jun 17 14:55:48 2009 From: nlewycky at google.com (Nick Lewycky) Date: Wed, 17 Jun 2009 12:55:48 -0700 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) In-Reply-To: <4A393785.8090202@gmail.com> References: <4A393785.8090202@gmail.com> Message-ID: 2009/6/17 T?r?k Edwin > Hi, > > I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't folded, > the attached patch folds this into: > umax (zext t1 %X to %t0, zext t1 %Y to %t0). > > It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext t1 > (umax (%X, %Y)) to %t0. > Unless I'm mistaken, we deliberately push them the other way so that we can eliminate ext(constant) inside of the umax. Also, since umax can take multiple operands we get to canonicalize "umax(zext(umax(a, b)), c)" into "umax(zext(a), zext(b), c)". There's an ordering defined in ScalarEvolutionExpressions.h (scConstant to scUnknown) which should match the inside-to-outside order that we want SCEVs to have when canonicalizing. > zext is very often encountered in SCEV expressions on x86-64, since > pointer indexes for GEP are i64. > > Thoughts? This is a real problem that deserves a fix, I'm just not sure I like the one proposed. How hard would it be to add logic to detect this case to the ScalarEvolutionExpander? Just look inside the umax and see whether all its operands contains the same zext/sext/trunc and hoist it then. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/c16003c1/attachment.html From resistor at mac.com Wed Jun 17 15:01:48 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 13:01:48 -0700 Subject: [llvm-commits] [llvm] r73620 - /llvm/trunk/lib/VMCore/Value.cpp In-Reply-To: References: <200906171737.n5HHb4TU029232@zion.cs.uiuc.edu> Message-ID: <952C6BF4-F449-472C-BCCD-B1F5ECA9F924@mac.com> On Jun 17, 2009, at 11:49 AM, Chris Lattner wrote: > > On Jun 17, 2009, at 10:37 AM, Owen Anderson wrote: > >> Author: resistor >> Date: Wed Jun 17 12:36:57 2009 >> New Revision: 73620 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=73620&view=rev >> Log: >> Protect the ValueHandle table. > > Owen, can you please add an RAII object to handle the locking and > unlocking? > > Instead of: > >> >> // Get the linked list base, which is guaranteed to exist since the >> // HasValueHandle flag is set. >> + if (llvm_is_multithreaded()) ValueHandlesLock->reader_acquire(); >> ValueHandleBase *Entry = (*ValueHandles)[V]; >> + if (llvm_is_multithreaded()) ValueHandlesLock->reader_release(); >> assert(Entry && "Value bit set but no entries exist"); > > > it would be very nice to have: > > { > RWReaderLocker X(*ValueHandlesLock); > Entry = (*ValueHandles)[V]; > } > ... Most of these examples are going away in the near future (by pushing the locking into the ValueMap from the callers), but I can certainly add it for the remaining cases. --Owen From criswell at uiuc.edu Wed Jun 17 15:05:42 2009 From: criswell at uiuc.edu (John Criswell) Date: Wed, 17 Jun 2009 20:05:42 -0000 Subject: [llvm-commits] [poolalloc] r73627 - /poolalloc/trunk/tools/Pa/Makefile Message-ID: <200906172005.n5HK5gwl002592@zion.cs.uiuc.edu> Author: criswell Date: Wed Jun 17 15:05:42 2009 New Revision: 73627 URL: http://llvm.org/viewvc/llvm-project?rev=73627&view=rev Log: Link in the archive version of the libraries since relinked versions are no longer built by the LLVM Makefile machinery. Modified: poolalloc/trunk/tools/Pa/Makefile Modified: poolalloc/trunk/tools/Pa/Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/tools/Pa/Makefile?rev=73627&r1=73626&r2=73627&view=diff ============================================================================== --- poolalloc/trunk/tools/Pa/Makefile (original) +++ poolalloc/trunk/tools/Pa/Makefile Wed Jun 17 15:05:42 2009 @@ -14,7 +14,7 @@ LINK_COMPONENTS := bitreader bitwriter instrumentation scalaropts ipo \ nativecodegen -USEDLIBS := poolalloc LLVMDataStructure +USEDLIBS := poolalloc.a LLVMDataStructure.a # Include this here so we can get the configuration of the targets # that have been configured for construction. We have to do this From edwintorok at gmail.com Wed Jun 17 15:07:39 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 17 Jun 2009 23:07:39 +0300 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) In-Reply-To: References: <4A393785.8090202@gmail.com> Message-ID: <4A394D0B.9070605@gmail.com> On 2009-06-17 22:55, Nick Lewycky wrote: > 2009/6/17 T?r?k Edwin > > > Hi, > > I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't > folded, > the attached patch folds this into: > umax (zext t1 %X to %t0, zext t1 %Y to %t0). > > It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext t1 > (umax (%X, %Y)) to %t0. > > > Unless I'm mistaken, we deliberately push them the other way so that > we can eliminate ext(constant) inside of the umax. Also, since umax > can take multiple operands we get to canonicalize "umax(zext(umax(a, > b)), c)" into "umax(zext(a), zext(b), c)". > > There's an ordering defined in ScalarEvolutionExpressions.h > (scConstant to scUnknown) which should match the inside-to-outside > order that we want SCEVs to have when canonicalizing. Ok, this is the wrong approach then, since I could possibly infloop if SCEV prefers the original ordering. > > > zext is very often encountered in SCEV expressions on x86-64, since > pointer indexes for GEP are i64. > > Thoughts? > > > This is a real problem that deserves a fix, I'm just not sure I like > the one proposed. How hard would it be to add logic to detect this > case to the ScalarEvolutionExpander? Just look inside the umax and see > whether all its operands contains the same zext/sext/trunc and hoist > it then. Yes, that would be possible. However I would prefer a utility function is ScalarEvolution that given a SCEV* transforms it into a SCEV* with minimal operations. ScalarEvolutionExpander could use that, and so could other clients of ScalarEvolution. As initial implementation it could transform OP1(OP2(a1), OP2(a2), ..., OP2(aN)) -> OP2(OP1(a1, ..., aN)). Besides umax for OP1, and zext/sext for OP2 is there any other situation where this transform would be valid? Best regards, --Edwin From resistor at mac.com Wed Jun 17 15:10:08 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 20:10:08 -0000 Subject: [llvm-commits] [llvm] r73628 - /llvm/trunk/lib/VMCore/Constants.cpp Message-ID: <200906172010.n5HKA8aR002724@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 15:10:08 2009 New Revision: 73628 URL: http://llvm.org/viewvc/llvm-project?rev=73628&view=rev Log: Simplify the locking on the Constants tables, and make it more efficient, by pushing it into the ValueMap from the callers. Document those ValueMap functions that are _not_ locked, so that callers are aware that they need to do the locking themselves. Modified: llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73628&r1=73627&r2=73628&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Wed Jun 17 15:10:08 2009 @@ -1183,6 +1183,8 @@ AbstractTypeMapTy AbstractTypeMap; public: + // NOTE: This function is not locked. It is the caller's responsibility + // to enforce proper synchronization. typename MapTy::iterator map_end() { return Map.end(); } /// InsertOrGetItem - Return an iterator for the specified element. @@ -1190,6 +1192,8 @@ /// entry and Exists=true. If not, the iterator points to the newly /// inserted entry and returns Exists=false. Newly inserted entries have /// I->second == 0, and should be filled in. + /// NOTE: This function is not locked. It is the caller's responsibility + // to enforce proper synchronization. typename MapTy::iterator InsertOrGetItem(std::pair &InsertVal, bool &Exists) { @@ -1225,37 +1229,85 @@ /// necessary. ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { MapKey Lookup(Ty, V); - typename MapTy::iterator I = Map.find(Lookup); - // Is it in the map? - if (I != Map.end()) - return static_cast(I->second); - - // If no preexisting value, create one now... - ConstantClass *Result = - ConstantCreator::create(Ty, V); - - assert(Result->getType() == Ty && "Type specified is not correct!"); - I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); - - if (HasLargeKey) // Remember the reverse mapping if needed. - InverseMap.insert(std::make_pair(Result, I)); - - // If the type of the constant is abstract, make sure that an entry exists - // for it in the AbstractTypeMap. - if (Ty->isAbstract()) { - typename AbstractTypeMapTy::iterator TI = AbstractTypeMap.find(Ty); - - if (TI == AbstractTypeMap.end()) { - // Add ourselves to the ATU list of the type. - cast(Ty)->addAbstractTypeUser(this); - - AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); + if (llvm_is_multithreaded()) { + ConstantClass* Result = 0; + + ConstantsLock->reader_acquire(); + typename MapTy::iterator I = Map.find(Lookup); + // Is it in the map? + if (I != Map.end()) + Result = static_cast(I->second); + ConstantsLock->reader_release(); + + if (!Result) { + ConstantsLock->writer_acquire(); + I = Map.find(Lookup); + // Is it in the map? + if (I != Map.end()) + Result = static_cast(I->second); + if (!Result) { + // If no preexisting value, create one now... + Result = + ConstantCreator::create(Ty, V); + + assert(Result->getType() == Ty && "Type specified is not correct!"); + I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); + + if (HasLargeKey) // Remember the reverse mapping if needed. + InverseMap.insert(std::make_pair(Result, I)); + + // If the type of the constant is abstract, make sure that an entry + // exists for it in the AbstractTypeMap. + if (Ty->isAbstract()) { + typename AbstractTypeMapTy::iterator TI = + AbstractTypeMap.find(Ty); + + if (TI == AbstractTypeMap.end()) { + // Add ourselves to the ATU list of the type. + cast(Ty)->addAbstractTypeUser(this); + + AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); + } + } + } + ConstantsLock->writer_release(); } + + return Result; + } else { + typename MapTy::iterator I = Map.find(Lookup); + // Is it in the map? + if (I != Map.end()) + return static_cast(I->second); + + // If no preexisting value, create one now... + ConstantClass *Result = + ConstantCreator::create(Ty, V); + + assert(Result->getType() == Ty && "Type specified is not correct!"); + I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); + + if (HasLargeKey) // Remember the reverse mapping if needed. + InverseMap.insert(std::make_pair(Result, I)); + + // If the type of the constant is abstract, make sure that an entry + // exists for it in the AbstractTypeMap. + if (Ty->isAbstract()) { + typename AbstractTypeMapTy::iterator TI = AbstractTypeMap.find(Ty); + + if (TI == AbstractTypeMap.end()) { + // Add ourselves to the ATU list of the type. + cast(Ty)->addAbstractTypeUser(this); + + AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); + } + } + return Result; } - return Result; } void remove(ConstantClass *CP) { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); typename MapTy::iterator I = FindExistingElement(CP); assert(I != Map.end() && "Constant not found in constant table!"); assert(I->second == CP && "Didn't find correct element?"); @@ -1303,12 +1355,16 @@ } Map.erase(I); + + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); } /// MoveConstantToNewSlot - If we are about to change C to be the element /// specified by I, update our internal data structures to reflect this /// fact. + /// NOTE: This function is not locked. It is the responsibility of the + /// caller to enforce proper synchronization if using this method. void MoveConstantToNewSlot(ConstantClass *C, typename MapTy::iterator I) { // First, remove the old location of the specified constant in the map. typename MapTy::iterator OldI = FindExistingElement(C); @@ -1338,6 +1394,7 @@ } void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); typename AbstractTypeMapTy::iterator I = AbstractTypeMap.find(cast(OldTy)); @@ -1355,12 +1412,16 @@ I = AbstractTypeMap.find(cast(OldTy)); } while (I != AbstractTypeMap.end()); + + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); } // If the type became concrete without being refined to any other existing // type, we just remove ourselves from the ATU list. void typeBecameConcrete(const DerivedType *AbsTy) { + if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); AbsTy->removeAbstractTypeUser(this); + if (llvm_is_multithreaded()) ConstantsLock->writer_release(); } void dump() const { @@ -1402,19 +1463,16 @@ ConstantAggregateZero *ConstantAggregateZero::get(const Type *Ty) { assert((isa(Ty) || isa(Ty) || isa(Ty)) && "Cannot create an aggregate zero of non-aggregate type!"); - ConstantAggregateZero* result = 0; - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - result = AggZeroConstants->getOrCreate(Ty, 0); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return AggZeroConstants->getOrCreate(Ty, 0); } /// destroyConstant - Remove the constant from the constant table... /// void ConstantAggregateZero::destroyConstant() { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + // Implicitly locked. AggZeroConstants->remove(this); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -1451,20 +1509,18 @@ Constant *ConstantArray::get(const ArrayType *Ty, const std::vector &V) { // If this is an all-zero array, return a ConstantAggregateZero object - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); if (!V.empty()) { Constant *C = V[0]; if (!C->isNullValue()) { - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + // Implicitly locked. return ArrayConstants->getOrCreate(Ty, V); } for (unsigned i = 1, e = V.size(); i != e; ++i) if (V[i] != C) { - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + // Implicitly locked. return ArrayConstants->getOrCreate(Ty, V); } } - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); return ConstantAggregateZero::get(Ty); } @@ -1472,9 +1528,7 @@ /// destroyConstant - Remove the constant from the constant table... /// void ConstantArray::destroyConstant() { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); ArrayConstants->remove(this); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -1583,14 +1637,10 @@ Constant *ConstantStruct::get(const StructType *Ty, const std::vector &V) { // Create a ConstantAggregateZero value if all elements are zeros... - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); for (unsigned i = 0, e = V.size(); i != e; ++i) - if (!V[i]->isNullValue()) { - Constant* result = StructConstants->getOrCreate(Ty, V); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; - } - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + if (!V[i]->isNullValue()) + // Implicitly locked. + return StructConstants->getOrCreate(Ty, V); return ConstantAggregateZero::get(Ty); } @@ -1606,9 +1656,7 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantStruct::destroyConstant() { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); StructConstants->remove(this); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); destroyConstantImpl(); } @@ -1662,10 +1710,9 @@ return ConstantAggregateZero::get(Ty); if (isUndef) return UndefValue::get(Ty); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = VectorConstants->getOrCreate(Ty, V); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return VectorConstants->getOrCreate(Ty, V); } Constant *ConstantVector::get(const std::vector &V) { @@ -1742,10 +1789,8 @@ ConstantPointerNull *ConstantPointerNull::get(const PointerType *Ty) { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - ConstantPointerNull* result = NullPtrConstants->getOrCreate(Ty, 0); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + // Implicitly locked. + return NullPtrConstants->getOrCreate(Ty, 0); } // destroyConstant - Remove the constant from the constant table... @@ -1790,18 +1835,15 @@ UndefValue *UndefValue::get(const Type *Ty) { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - UndefValue* result = UndefValueConstants->getOrCreate(Ty, 0); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + // Implicitly locked. + return UndefValueConstants->getOrCreate(Ty, 0); } // destroyConstant - Remove the constant from the constant table. // void UndefValue::destroyConstant() { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + // Implicitly locked. UndefValueConstants->remove(this); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); destroyConstantImpl(); } @@ -2055,10 +2097,8 @@ std::vector argVec(1, C); ExprMapKeyType Key(opc, argVec); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = ExprConstants->getOrCreate(Ty, Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + // Implicitly locked. + return ExprConstants->getOrCreate(Ty, Key); } Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty) { @@ -2318,10 +2358,9 @@ std::vector argVec(1, C1); argVec.push_back(C2); ExprMapKeyType Key(Opcode, argVec); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = ExprConstants->getOrCreate(ReqTy, Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return ExprConstants->getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getCompareTy(unsigned short predicate, @@ -2432,10 +2471,9 @@ argVec[1] = V1; argVec[2] = V2; ExprMapKeyType Key(Instruction::Select, argVec); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = ExprConstants->getOrCreate(ReqTy, Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return ExprConstants->getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getGetElementPtrTy(const Type *ReqTy, Constant *C, @@ -2458,10 +2496,9 @@ for (unsigned i = 0; i != NumIdx; ++i) ArgVec.push_back(cast(Idxs[i])); const ExprMapKeyType Key(Instruction::GetElementPtr, ArgVec); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant *result = ExprConstants->getOrCreate(ReqTy, Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return ExprConstants->getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getGetElementPtr(Constant *C, Value* const *Idxs, @@ -2495,10 +2532,9 @@ ArgVec.push_back(RHS); // Get the key type with both the opcode and predicate const ExprMapKeyType Key(Instruction::ICmp, ArgVec, pred); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = ExprConstants->getOrCreate(Type::Int1Ty, Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return ExprConstants->getOrCreate(Type::Int1Ty, Key); } Constant * @@ -2515,10 +2551,9 @@ ArgVec.push_back(RHS); // Get the key type with both the opcode and predicate const ExprMapKeyType Key(Instruction::FCmp, ArgVec, pred); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = ExprConstants->getOrCreate(Type::Int1Ty, Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return ExprConstants->getOrCreate(Type::Int1Ty, Key); } Constant * @@ -2563,10 +2598,9 @@ ArgVec.push_back(RHS); // Get the key type with both the opcode and predicate const ExprMapKeyType Key(Instruction::VICmp, ArgVec, pred); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = ExprConstants->getOrCreate(LHS->getType(), Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return ExprConstants->getOrCreate(LHS->getType(), Key); } Constant * @@ -2613,10 +2647,9 @@ ArgVec.push_back(RHS); // Get the key type with both the opcode and predicate const ExprMapKeyType Key(Instruction::VFCmp, ArgVec, pred); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = ExprConstants->getOrCreate(ResultTy, Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return ExprConstants->getOrCreate(ResultTy, Key); } Constant *ConstantExpr::getExtractElementTy(const Type *ReqTy, Constant *Val, @@ -2627,10 +2660,9 @@ std::vector ArgVec(1, Val); ArgVec.push_back(Idx); const ExprMapKeyType Key(Instruction::ExtractElement,ArgVec); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = ExprConstants->getOrCreate(ReqTy, Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return ExprConstants->getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getExtractElement(Constant *Val, Constant *Idx) { @@ -2651,10 +2683,9 @@ ArgVec.push_back(Elt); ArgVec.push_back(Idx); const ExprMapKeyType Key(Instruction::InsertElement,ArgVec); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = ExprConstants->getOrCreate(ReqTy, Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return ExprConstants->getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getInsertElement(Constant *Val, Constant *Elt, @@ -2677,10 +2708,9 @@ ArgVec.push_back(V2); ArgVec.push_back(Mask); const ExprMapKeyType Key(Instruction::ShuffleVector,ArgVec); - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - Constant* result = ExprConstants->getOrCreate(ReqTy, Key); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return result; + + // Implicitly locked. + return ExprConstants->getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getShuffleVector(Constant *V1, Constant *V2, From nlewycky at google.com Wed Jun 17 15:24:23 2009 From: nlewycky at google.com (Nick Lewycky) Date: Wed, 17 Jun 2009 13:24:23 -0700 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) In-Reply-To: <4A394D0B.9070605@gmail.com> References: <4A393785.8090202@gmail.com> <4A394D0B.9070605@gmail.com> Message-ID: 2009/6/17 T?r?k Edwin > On 2009-06-17 22:55, Nick Lewycky wrote: > > 2009/6/17 T?r?k Edwin >> > > > > Hi, > > > > I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't > > folded, > > the attached patch folds this into: > > umax (zext t1 %X to %t0, zext t1 %Y to %t0). > > > > It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext t1 > > (umax (%X, %Y)) to %t0. > > > > > > Unless I'm mistaken, we deliberately push them the other way so that > > we can eliminate ext(constant) inside of the umax. Also, since umax > > can take multiple operands we get to canonicalize "umax(zext(umax(a, > > b)), c)" into "umax(zext(a), zext(b), c)". > > > > There's an ordering defined in ScalarEvolutionExpressions.h > > (scConstant to scUnknown) which should match the inside-to-outside > > order that we want SCEVs to have when canonicalizing. > > Ok, this is the wrong approach then, since I could possibly infloop if > SCEV prefers the original ordering. > Exactly. If your patch doesn't cause infinite loops it might mean that the zext(umax) optimization never happens. Checking this would be a good sanity check. > zext is very often encountered in SCEV expressions on x86-64, since > > pointer indexes for GEP are i64. > > > > Thoughts? > > > > > > This is a real problem that deserves a fix, I'm just not sure I like > > the one proposed. How hard would it be to add logic to detect this > > case to the ScalarEvolutionExpander? Just look inside the umax and see > > whether all its operands contains the same zext/sext/trunc and hoist > > it then. > > Yes, that would be possible. However I would prefer a utility function > is ScalarEvolution that given a SCEV* transforms it into a SCEV* with > minimal operations. > ScalarEvolutionExpander could use that, and so could other clients of > ScalarEvolution. > > As initial implementation it could transform OP1(OP2(a1), OP2(a2), ..., > OP2(aN)) -> OP2(OP1(a1, ..., aN)). > Besides umax for OP1, and zext/sext for OP2 is there any other situation > where this transform would be valid? OP1 = smax and OP2 = sext. I think that's it. The other transformations SEE wants to do can't be easily represented with SCEVs, like mul(x, -1) to xor(x, -1) and add(x, 4) to or(x, 4). Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/a4cad688/attachment.html From gohman at apple.com Wed Jun 17 15:25:25 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Jun 2009 13:25:25 -0700 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) In-Reply-To: <4A393785.8090202@gmail.com> References: <4A393785.8090202@gmail.com> Message-ID: <6C8ECC3B-BE0E-4D05-92B4-926E9FF6CD8B@apple.com> On Jun 17, 2009, at 11:35 AM, T?r?k Edwin wrote: > Hi, > > I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't > folded, > the attached patch folds this into: > umax (zext t1 %X to %t0, zext t1 %Y to %t0). > > It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext t1 > (umax (%X, %Y)) to %t0. > > zext is very often encountered in SCEV expressions on x86-64, since > pointer indexes for GEP are i64. > > Thoughts? Another question to ask is whether this kind of thing belongs in ScalarEvolution, or if it would be more appropriate for instcombine. Instcombine looks at all instructions in a program, while ScalarEvolution typically only looks at those related to loop iteration. Also, instcombine could more easily handle more generalized cases of this optimization, for example with umin. On the other hand, there are cases where it makes sense to do such simplifications in ScalarEvolution. Can you given an example where you're seeing this kind of code? One minor note on the patch itself: > + unsigned bits = Ty->getPrimitiveSizeInBits(); > + if (!bits) { [...] > + if (maxBits) { Within ScalarEvolution code, you can use ScalarEvolution::getTypeSizeInBits, which has the advantage of TargetData information (when available). Using that instead of getPrimitiveSizeInBits would eliminate the need for the two if statements quoted here. Dan From isanbard at gmail.com Wed Jun 17 15:30:40 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 17 Jun 2009 13:30:40 -0700 Subject: [llvm-commits] [llvm] r73628 - /llvm/trunk/lib/VMCore/Constants.cpp In-Reply-To: <200906172010.n5HKA8aR002724@zion.cs.uiuc.edu> References: <200906172010.n5HKA8aR002724@zion.cs.uiuc.edu> Message-ID: <16e5fdf90906171330s76ff57a0o7f19dcea54ef3952@mail.gmail.com> On Wed, Jun 17, 2009 at 1:10 PM, Owen Anderson wrote: > --- llvm/trunk/lib/VMCore/Constants.cpp (original) > +++ llvm/trunk/lib/VMCore/Constants.cpp Wed Jun 17 15:10:08 2009 > @@ -1225,37 +1229,85 @@ > ? ? /// necessary. > ? ? ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { > ? ? ? MapKey Lookup(Ty, V); > - ? ? ?typename MapTy::iterator I = Map.find(Lookup); > - ? ? ?// Is it in the map? > - ? ? ?if (I != Map.end()) > - ? ? ? ?return static_cast(I->second); > - > - ? ? ?// If no preexisting value, create one now... > - ? ? ?ConstantClass *Result = > - ? ? ? ?ConstantCreator::create(Ty, V); > - > - ? ? ?assert(Result->getType() == Ty && "Type specified is not correct!"); > - ? ? ?I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); > - > - ? ? ?if (HasLargeKey) ?// Remember the reverse mapping if needed. > - ? ? ? ?InverseMap.insert(std::make_pair(Result, I)); > - > - ? ? ?// If the type of the constant is abstract, make sure that an entry exists > - ? ? ?// for it in the AbstractTypeMap. > - ? ? ?if (Ty->isAbstract()) { > - ? ? ? ?typename AbstractTypeMapTy::iterator TI = AbstractTypeMap.find(Ty); > - > - ? ? ? ?if (TI == AbstractTypeMap.end()) { > - ? ? ? ? ?// Add ourselves to the ATU list of the type. > - ? ? ? ? ?cast(Ty)->addAbstractTypeUser(this); > - > - ? ? ? ? ?AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); > + ? ? ?if (llvm_is_multithreaded()) { > + ? ? ? ?ConstantClass* Result = 0; > + > + ? ? ? ?ConstantsLock->reader_acquire(); > + ? ? ? ?typename MapTy::iterator I = Map.find(Lookup); > + ? ? ? ?// Is it in the map? > + ? ? ? ?if (I != Map.end()) > + ? ? ? ? ?Result = static_cast(I->second); > + ? ? ? ?ConstantsLock->reader_release(); > + > + ? ? ? ?if (!Result) { > + ? ? ? ? ?ConstantsLock->writer_acquire(); > + ? ? ? ? ?I = Map.find(Lookup); > + ? ? ? ? ?// Is it in the map? > + ? ? ? ? ?if (I != Map.end()) > + ? ? ? ? ? ?Result = static_cast(I->second); > + ? ? ? ? ?if (!Result) { > + ? ? ? ? ? ?// If no preexisting value, create one now... > + ? ? ? ? ? ?Result = > + ? ? ? ? ? ? ?ConstantCreator::create(Ty, V); > + > + ? ? ? ? ? ?assert(Result->getType() == Ty && "Type specified is not correct!"); > + ? ? ? ? ? ?I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); > + > + ? ? ? ? ? ?if (HasLargeKey) ?// Remember the reverse mapping if needed. > + ? ? ? ? ? ? ?InverseMap.insert(std::make_pair(Result, I)); > + > + ? ? ? ? ? ?// If the type of the constant is abstract, make sure that an entry > + ? ? ? ? ? ?// exists for it in the AbstractTypeMap. > + ? ? ? ? ? ?if (Ty->isAbstract()) { > + ? ? ? ? ? ? ?typename AbstractTypeMapTy::iterator TI = > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? AbstractTypeMap.find(Ty); > + > + ? ? ? ? ? ? ?if (TI == AbstractTypeMap.end()) { > + ? ? ? ? ? ? ? ?// Add ourselves to the ATU list of the type. > + ? ? ? ? ? ? ? ?cast(Ty)->addAbstractTypeUser(this); > + > + ? ? ? ? ? ? ? ?AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); > + ? ? ? ? ? ? ?} > + ? ? ? ? ? ?} > + ? ? ? ? ?} > + ? ? ? ? ?ConstantsLock->writer_release(); > ? ? ? ? } Owen, Could you revisit and rework this so that so much code isn't copied in the if-then-else statement? -bw From resistor at mac.com Wed Jun 17 15:34:44 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 20:34:44 -0000 Subject: [llvm-commits] [llvm] r73630 - in /llvm/trunk: include/llvm/System/RWMutex.h lib/VMCore/Constants.cpp Message-ID: <200906172034.n5HKYifR003583@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 15:34:43 2009 New Revision: 73630 URL: http://llvm.org/viewvc/llvm-project?rev=73630&view=rev Log: Add an RAII ScopedWriter, which allows one to acquire a writer lock for the duration of a scope. Simplify a lot of uses of writer locks in Constants.cpp by using it. Modified: llvm/trunk/include/llvm/System/RWMutex.h llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/include/llvm/System/RWMutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/RWMutex.h?rev=73630&r1=73629&r2=73630&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/RWMutex.h (original) +++ llvm/trunk/include/llvm/System/RWMutex.h Wed Jun 17 15:34:43 2009 @@ -78,6 +78,20 @@ void operator=(const RWMutex &); /// @} }; + + /// ScopedWriter - RAII acquisition of a writer lock + struct ScopedWriter { + RWMutex* mutex; + + explicit ScopedWriter(RWMutex* m) { + mutex = m; + mutex->writer_acquire(); + } + + ~ScopedWriter() { + mutex->writer_release(); + } + }; } } Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73630&r1=73629&r2=73630&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Wed Jun 17 15:34:43 2009 @@ -306,12 +306,11 @@ ConstantsLock->reader_release(); if (!Slot) { - ConstantsLock->writer_acquire(); + sys::ScopedWriter Writer(&*ConstantsLock); ConstantInt *&Slot = (*IntConstants)[Key]; if (!Slot) { Slot = new ConstantInt(ITy, V); } - ConstantsLock->writer_release(); } return Slot; @@ -421,7 +420,7 @@ ConstantsLock->reader_release(); if (!Slot) { - ConstantsLock->writer_acquire(); + sys::ScopedWriter Writer(&*ConstantsLock); Slot = (*FPConstants)[Key]; if (!Slot) { const Type *Ty; @@ -441,7 +440,6 @@ Slot = new ConstantFP(Ty, V); } - ConstantsLock->writer_release(); } return Slot; @@ -1240,7 +1238,7 @@ ConstantsLock->reader_release(); if (!Result) { - ConstantsLock->writer_acquire(); + sys::ScopedWriter Writer(&*ConstantsLock); I = Map.find(Lookup); // Is it in the map? if (I != Map.end()) @@ -1270,7 +1268,6 @@ } } } - ConstantsLock->writer_release(); } return Result; @@ -1419,9 +1416,11 @@ // If the type became concrete without being refined to any other existing // type, we just remove ourselves from the ATU list. void typeBecameConcrete(const DerivedType *AbsTy) { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - AbsTy->removeAbstractTypeUser(this); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + if (llvm_is_multithreaded()) { + sys::ScopedWriter Writer(&*ConstantsLock); + AbsTy->removeAbstractTypeUser(this); + } else + AbsTy->removeAbstractTypeUser(this); } void dump() const { @@ -1723,9 +1722,12 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantVector::destroyConstant() { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - VectorConstants->remove(this); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + + if (llvm_is_multithreaded()) { + sys::ScopedWriter Write(&*ConstantsLock); + VectorConstants->remove(this); + } else + VectorConstants->remove(this); destroyConstantImpl(); } @@ -1796,9 +1798,11 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantPointerNull::destroyConstant() { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - NullPtrConstants->remove(this); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + if (llvm_is_multithreaded()) { + sys::ScopedWriter Writer(&*ConstantsLock); + NullPtrConstants->remove(this); + } else + NullPtrConstants->remove(this); destroyConstantImpl(); } @@ -1857,21 +1861,33 @@ static ManagedStatic > MDStringCache; MDString *MDString::get(const char *StrBegin, const char *StrEnd) { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - StringMapEntry &Entry = MDStringCache->GetOrCreateValue(StrBegin, - StrEnd); - MDString *&S = Entry.getValue(); - if (!S) S = new MDString(Entry.getKeyData(), - Entry.getKeyData() + Entry.getKeyLength()); - - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); - return S; + if (llvm_is_multithreaded()) { + sys::ScopedWriter Writer(&*ConstantsLock); + StringMapEntry &Entry = MDStringCache->GetOrCreateValue( + StrBegin, StrEnd); + MDString *&S = Entry.getValue(); + if (!S) S = new MDString(Entry.getKeyData(), + Entry.getKeyData() + Entry.getKeyLength()); + + return S; + } else { + StringMapEntry &Entry = MDStringCache->GetOrCreateValue( + StrBegin, StrEnd); + MDString *&S = Entry.getValue(); + if (!S) S = new MDString(Entry.getKeyData(), + Entry.getKeyData() + Entry.getKeyLength()); + + return S; + } } void MDString::destroyConstant() { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd)); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + if (llvm_is_multithreaded()) { + sys::ScopedWriter Writer(&*ConstantsLock); + MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd)); + } else + MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd)); + destroyConstantImpl(); } @@ -1903,14 +1919,13 @@ ConstantsLock->reader_release(); if (!N) { - ConstantsLock->writer_acquire(); + sys::ScopedWriter Writer(&*ConstantsLock); N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); if (!N) { // InsertPoint will have been set by the FindNodeOrInsertPos call. MDNode *N = new(0) MDNode(Vals, NumVals); MDNodeSet->InsertNode(N, InsertPoint); } - ConstantsLock->writer_release(); } return N; @@ -1927,9 +1942,12 @@ } void MDNode::destroyConstant() { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - MDNodeSet->RemoveNode(this); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + if (llvm_is_multithreaded()) { + sys::ScopedWriter Writer(&*ConstantsLock); + MDNodeSet->RemoveNode(this); + } else + MDNodeSet->RemoveNode(this); + destroyConstantImpl(); } @@ -2793,9 +2811,12 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantExpr::destroyConstant() { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); - ExprConstants->remove(this); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + if (llvm_is_multithreaded()) { + sys::ScopedWriter Writer(&*ConstantsLock); + ExprConstants->remove(this); + } else + ExprConstants->remove(this); + destroyConstantImpl(); } @@ -2859,7 +2880,7 @@ Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + sys::ScopedWriter Writer(&*ConstantsLock); bool Exists; ArrayConstantsTy::MapTy::iterator I = ArrayConstants->InsertOrGetItem(Lookup, Exists); @@ -2885,10 +2906,8 @@ if (getOperand(i) == From) setOperand(i, ToC); } - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); return; } - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); } // Otherwise, I do need to replace this with an existing value. @@ -2937,7 +2956,7 @@ Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + sys::ScopedWriter Writer(&*ConstantsLock); bool Exists; StructConstantsTy::MapTy::iterator I = StructConstants->InsertOrGetItem(Lookup, Exists); @@ -2953,10 +2972,8 @@ // Update to the new value. setOperand(OperandToUpdate, ToC); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); return; } - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); } assert(Replacement != this && "I didn't contain From!"); From resistor at mac.com Wed Jun 17 15:43:40 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 20:43:40 -0000 Subject: [llvm-commits] [llvm] r73631 - /llvm/trunk/lib/VMCore/Constants.cpp Message-ID: <200906172043.n5HKhelC004034@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 15:43:39 2009 New Revision: 73631 URL: http://llvm.org/viewvc/llvm-project?rev=73631&view=rev Log: Factor out some common code. Modified: llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73631&r1=73630&r2=73631&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Wed Jun 17 15:43:39 2009 @@ -1221,6 +1221,34 @@ } return I; } + + ConstantClass* Create(const TypeClass *Ty, const ValType &V, + typename MapTy::iterator I) { + ConstantClass* Result = + ConstantCreator::create(Ty, V); + + assert(Result->getType() == Ty && "Type specified is not correct!"); + I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); + + if (HasLargeKey) // Remember the reverse mapping if needed. + InverseMap.insert(std::make_pair(Result, I)); + + // If the type of the constant is abstract, make sure that an entry + // exists for it in the AbstractTypeMap. + if (Ty->isAbstract()) { + typename AbstractTypeMapTy::iterator TI = + AbstractTypeMap.find(Ty); + + if (TI == AbstractTypeMap.end()) { + // Add ourselves to the ATU list of the type. + cast(Ty)->addAbstractTypeUser(this); + + AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); + } + } + + return Result; + } public: /// getOrCreate - Return the specified constant from the map, creating it if @@ -1245,28 +1273,7 @@ Result = static_cast(I->second); if (!Result) { // If no preexisting value, create one now... - Result = - ConstantCreator::create(Ty, V); - - assert(Result->getType() == Ty && "Type specified is not correct!"); - I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); - - if (HasLargeKey) // Remember the reverse mapping if needed. - InverseMap.insert(std::make_pair(Result, I)); - - // If the type of the constant is abstract, make sure that an entry - // exists for it in the AbstractTypeMap. - if (Ty->isAbstract()) { - typename AbstractTypeMapTy::iterator TI = - AbstractTypeMap.find(Ty); - - if (TI == AbstractTypeMap.end()) { - // Add ourselves to the ATU list of the type. - cast(Ty)->addAbstractTypeUser(this); - - AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); - } - } + Result = Create(Ty, V, I); } } @@ -1278,28 +1285,7 @@ return static_cast(I->second); // If no preexisting value, create one now... - ConstantClass *Result = - ConstantCreator::create(Ty, V); - - assert(Result->getType() == Ty && "Type specified is not correct!"); - I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); - - if (HasLargeKey) // Remember the reverse mapping if needed. - InverseMap.insert(std::make_pair(Result, I)); - - // If the type of the constant is abstract, make sure that an entry - // exists for it in the AbstractTypeMap. - if (Ty->isAbstract()) { - typename AbstractTypeMapTy::iterator TI = AbstractTypeMap.find(Ty); - - if (TI == AbstractTypeMap.end()) { - // Add ourselves to the ATU list of the type. - cast(Ty)->addAbstractTypeUser(this); - - AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); - } - } - return Result; + return Create(Ty, V, I); } } From edwintorok at gmail.com Wed Jun 17 15:44:25 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 17 Jun 2009 23:44:25 +0300 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) In-Reply-To: <6C8ECC3B-BE0E-4D05-92B4-926E9FF6CD8B@apple.com> References: <4A393785.8090202@gmail.com> <6C8ECC3B-BE0E-4D05-92B4-926E9FF6CD8B@apple.com> Message-ID: <4A3955A9.4040300@gmail.com> On 2009-06-17 23:25, Dan Gohman wrote: > On Jun 17, 2009, at 11:35 AM, T?r?k Edwin wrote: > > >> Hi, >> >> I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't >> folded, >> the attached patch folds this into: >> umax (zext t1 %X to %t0, zext t1 %Y to %t0). >> >> It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext t1 >> (umax (%X, %Y)) to %t0. >> >> zext is very often encountered in SCEV expressions on x86-64, since >> pointer indexes for GEP are i64. >> >> Thoughts? >> > > Another question to ask is whether this kind of thing belongs in > ScalarEvolution, or if it would be more appropriate for > instcombine. Instcombine looks at all instructions in a program, > while ScalarEvolution typically only looks at those related to > loop iteration. Also, instcombine could more easily handle more > generalized cases of this optimization, for example with umin. > > On the other hand, there are cases where it makes sense to do > such simplifications in ScalarEvolution. Can you given an > example where you're seeing this kind of code? > It doesn't have much to do with code generation/optimization, but rather with analysis. I have a pass that tries to find buffer overflow bugs, doing that involves lots of umax() expressions. If I can move the zext out of umax I can decide quite early that an access is valid: int foo(unsigned n, unsigned i) { char *a = malloc(n); if (!a) return -1; if (i < n) a[i]=0; } Compiling that on 32-bit, I can decide immediately. On 64-bit I need the additional step of getting rid of zexts inside umax. Of course a solver can decide either way (with zext or not), but for such a simple case I prefer to solve the equation early myself. Of course I could do this all in my pass, but I thought the SCEV code would benefit from it generally. Doing one zero ext, and one umax should be cheaper than 2 zero exts and one umax. Also its easier to analyze expressions if you don't have so many zero/sign extensions and truncations. > One minor note on the patch itself: > > > + unsigned bits = Ty->getPrimitiveSizeInBits(); > > + if (!bits) { > [...] > > + if (maxBits) { > > Within ScalarEvolution code, you can use > ScalarEvolution::getTypeSizeInBits, which has the advantage of > TargetData information (when available). Using that instead > of getPrimitiveSizeInBits would eliminate the need for the > two if statements quoted here. > Thanks, I'll use that in the next iteration of the patch (for sCEVExpander). Best regards, --Edwin From dalej at apple.com Wed Jun 17 15:48:23 2009 From: dalej at apple.com (Dale Johannesen) Date: Wed, 17 Jun 2009 20:48:23 -0000 Subject: [llvm-commits] [llvm] r73632 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/2009-06-17-InvalidPRE.ll test/Transforms/GVN/pre-single-pred.ll Message-ID: <200906172048.n5HKmN2P004234@zion.cs.uiuc.edu> Author: johannes Date: Wed Jun 17 15:48:23 2009 New Revision: 73632 URL: http://llvm.org/viewvc/llvm-project?rev=73632&view=rev Log: This fixes a bug introduced in 72661, which can move loads back past a check that the load address is valid, see new testcase. The test that went in with 72661 has exactly this case, except that the conditional it's moving past is checking something else; I've settled for changing that test to reference a global, not a pointer. It may be possible to scan all the tests you pass and make sure none of them are checking any component of the address, but it's not trivial and I'm not trying to do that here. Added: llvm/trunk/test/Transforms/GVN/2009-06-17-InvalidPRE.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/pre-single-pred.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=73632&r1=73631&r2=73632&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Jun 17 15:48:23 2009 @@ -37,6 +37,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" +#include "llvm/Transforms/Utils/Local.h" #include using namespace llvm; @@ -1075,6 +1076,7 @@ BasicBlock *TmpBB = LoadBB; bool isSinglePred = false; + bool allSingleSucc = true; while (TmpBB->getSinglePredecessor()) { isSinglePred = true; TmpBB = TmpBB->getSinglePredecessor(); @@ -1084,6 +1086,8 @@ return false; if (Blockers.count(TmpBB)) return false; + if (TmpBB->getTerminator()->getNumSuccessors() != 1) + allSingleSucc = false; } assert(TmpBB); @@ -1160,7 +1164,20 @@ << UnavailablePred->getName() << "': " << *LI); return false; } - + + // Make sure it is valid to move this load here. We have to watch out for: + // @1 = getelementptr (i8* p, ... + // test p and branch if == 0 + // load @1 + // It is valid to have the getelementptr before the test, even if p can be 0, + // as getelementptr only does address arithmetic. + // If we are not pushing the value through any multiple-successor blocks + // we do not have this case. Otherwise, check that the load is safe to + // put anywhere; this can be improved, but should be conservatively safe. + if (!allSingleSucc && + !isSafeToLoadUnconditionally(LoadPtr, UnavailablePred->getTerminator())) + return false; + // Okay, we can eliminate this load by inserting a reload in the predecessor // and using PHI construction to get the value in the other predecessors, do // it. Added: llvm/trunk/test/Transforms/GVN/2009-06-17-InvalidPRE.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/2009-06-17-InvalidPRE.ll?rev=73632&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/2009-06-17-InvalidPRE.ll (added) +++ llvm/trunk/test/Transforms/GVN/2009-06-17-InvalidPRE.ll Wed Jun 17 15:48:23 2009 @@ -0,0 +1,72 @@ +; RUN: llvm-as < %s | opt -gvn -enable-load-pre | llvm-dis | not grep pre1 +; GVN load pre was hoisting the loads at %13 and %16 up to bb4.outer. +; This is invalid as it bypasses the check for %m.0.ph==null in bb4. +; ModuleID = 'mbuf.c' +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-darwin9.6" + %struct.mbuf = type { %struct.mbuf*, %struct.mbuf*, i32, i8*, i16, i16, i32 } + +define void @m_adj(%struct.mbuf* %mp, i32 %req_len) nounwind optsize { +entry: + %0 = icmp eq %struct.mbuf* %mp, null ; [#uses=1] + %1 = icmp slt i32 %req_len, 0 ; [#uses=1] + %or.cond = or i1 %1, %0 ; [#uses=1] + br i1 %or.cond, label %return, label %bb4.preheader + +bb4.preheader: ; preds = %entry + br label %bb4.outer + +bb2: ; preds = %bb1 + %2 = sub i32 %len.0, %13 ; [#uses=1] + %3 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 2 ; [#uses=1] + store i32 0, i32* %3, align 4 + %4 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 0 ; <%struct.mbuf**> [#uses=1] + %5 = load %struct.mbuf** %4, align 4 ; <%struct.mbuf*> [#uses=1] + br label %bb4.outer + +bb4.outer: ; preds = %bb4.preheader, %bb2 + %m.0.ph = phi %struct.mbuf* [ %5, %bb2 ], [ %mp, %bb4.preheader ] ; <%struct.mbuf*> [#uses=7] + %len.0.ph = phi i32 [ %2, %bb2 ], [ %req_len, %bb4.preheader ] ; [#uses=1] + %6 = icmp ne %struct.mbuf* %m.0.ph, null ; [#uses=1] + %7 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 2 ; [#uses=1] + %8 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 2 ; [#uses=1] + %9 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 3 ; [#uses=1] + %10 = getelementptr %struct.mbuf* %m.0.ph, i32 0, i32 3 ; [#uses=1] + br label %bb4 + +bb4: ; preds = %bb4.outer, %bb3 + %len.0 = phi i32 [ 0, %bb3 ], [ %len.0.ph, %bb4.outer ] ; [#uses=6] + %11 = icmp sgt i32 %len.0, 0 ; [#uses=1] + %12 = and i1 %11, %6 ; [#uses=1] + br i1 %12, label %bb1, label %bb7 + +bb1: ; preds = %bb4 + %13 = load i32* %7, align 4 ; [#uses=3] + %14 = icmp sgt i32 %13, %len.0 ; [#uses=1] + br i1 %14, label %bb3, label %bb2 + +bb3: ; preds = %bb1 + %15 = sub i32 %13, %len.0 ; [#uses=1] + store i32 %15, i32* %8, align 4 + %16 = load i8** %9, align 4 ; [#uses=1] + %17 = getelementptr i8* %16, i32 %len.0 ; [#uses=1] + store i8* %17, i8** %10, align 4 + br label %bb4 + +bb7: ; preds = %bb4 + %18 = getelementptr %struct.mbuf* %mp, i32 0, i32 5 ; [#uses=1] + %19 = load i16* %18, align 2 ; [#uses=1] + %20 = zext i16 %19 to i32 ; [#uses=1] + %21 = and i32 %20, 2 ; [#uses=1] + %22 = icmp eq i32 %21, 0 ; [#uses=1] + br i1 %22, label %return, label %bb8 + +bb8: ; preds = %bb7 + %23 = sub i32 %req_len, %len.0 ; [#uses=1] + %24 = getelementptr %struct.mbuf* %mp, i32 0, i32 6 ; [#uses=1] + store i32 %23, i32* %24, align 4 + ret void + +return: ; preds = %bb7, %entry + ret void +} Modified: llvm/trunk/test/Transforms/GVN/pre-single-pred.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/pre-single-pred.ll?rev=73632&r1=73631&r2=73632&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/pre-single-pred.ll (original) +++ llvm/trunk/test/Transforms/GVN/pre-single-pred.ll Wed Jun 17 15:48:23 2009 @@ -1,6 +1,7 @@ ; RUN: llvm-as < %s | opt -gvn -enable-load-pre | llvm-dis | not grep {tmp3 = load} -define i32 @f(i32* nocapture %p, i32 %n) nounwind { + at p = external global i32 +define i32 @f(i32 %n) nounwind { entry: br label %for.cond @@ -13,9 +14,9 @@ br label %for.end for.body: ; preds = %for.cond - %tmp3 = load i32* %p ; [#uses=1] + %tmp3 = load i32* @p ; [#uses=1] %dec = add i32 %tmp3, -1 ; [#uses=2] - store i32 %dec, i32* %p + store i32 %dec, i32* @p %cmp6 = icmp slt i32 %dec, 0 ; [#uses=1] br i1 %cmp6, label %for.body.for.end_crit_edge, label %for.inc @@ -27,6 +28,6 @@ br label %for.cond for.end: ; preds = %for.body.for.end_crit_edge, %for.cond.for.end_crit_edge - %tmp9 = load i32* %p ; [#uses=1] + %tmp9 = load i32* @p ; [#uses=1] ret i32 %tmp9 } From edwintorok at gmail.com Wed Jun 17 15:50:19 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 17 Jun 2009 23:50:19 +0300 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) In-Reply-To: <6C8ECC3B-BE0E-4D05-92B4-926E9FF6CD8B@apple.com> References: <4A393785.8090202@gmail.com> <6C8ECC3B-BE0E-4D05-92B4-926E9FF6CD8B@apple.com> Message-ID: <4A39570B.3060907@gmail.com> On 2009-06-17 23:25, Dan Gohman wrote: > On Jun 17, 2009, at 11:35 AM, T?r?k Edwin wrote: > > >> Hi, >> >> I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't >> folded, >> the attached patch folds this into: >> umax (zext t1 %X to %t0, zext t1 %Y to %t0). >> >> It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext t1 >> (umax (%X, %Y)) to %t0. >> >> zext is very often encountered in SCEV expressions on x86-64, since >> pointer indexes for GEP are i64. >> >> Thoughts? >> > > Another question to ask is whether this kind of thing belongs in > ScalarEvolution, or if it would be more appropriate for > instcombine. Instcombine looks at all instructions in a program, > while ScalarEvolution typically only looks at those related to > loop iteration. Also, instcombine could more easily handle more > generalized cases of this optimization, for example with umin. > Yes, instcombine appears to do this transform already. Best regards, --Edwin From gohman at apple.com Wed Jun 17 15:56:26 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Jun 2009 20:56:26 -0000 Subject: [llvm-commits] [llvm] r73633 - in /llvm/trunk/test: Analysis/ScalarEvolution/ Transforms/IndVarSimplify/ Message-ID: <200906172056.n5HKuRlW004792@zion.cs.uiuc.edu> Author: djg Date: Wed Jun 17 15:56:26 2009 New Revision: 73633 URL: http://llvm.org/viewvc/llvm-project?rev=73633&view=rev Log: Add -disable-output to a bunch of tests that don't care about the output. Modified: llvm/trunk/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll llvm/trunk/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll llvm/trunk/test/Analysis/ScalarEvolution/2007-11-18-OrInstruction.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-11-15-CubicOOM.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-12-11-SMaxOverflow.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll llvm/trunk/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll llvm/trunk/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll llvm/trunk/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll llvm/trunk/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll llvm/trunk/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll llvm/trunk/test/Analysis/ScalarEvolution/avoid-smax-0.ll llvm/trunk/test/Analysis/ScalarEvolution/do-loop.ll llvm/trunk/test/Analysis/ScalarEvolution/smax.ll llvm/trunk/test/Analysis/ScalarEvolution/trip-count.ll llvm/trunk/test/Analysis/ScalarEvolution/trip-count2.ll llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll Modified: llvm/trunk/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2007-07-15-NegativeStride.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \ ; RUN: -scalar-evolution-max-iterations=0 | grep {Loop bb: backedge-taken count is 100} ; PR1533 Modified: llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2007-08-06-Unsigned.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -scalar-evolution -analyze | grep {Loop bb: backedge-taken count is (-1 + (-1 \\* %x) + %y)} +; RUN: llvm-as < %s | opt -scalar-evolution -analyze -disable-output | grep {Loop bb: backedge-taken count is (-1 + (-1 \\* %x) + %y)} ; PR1597 define i32 @f(i32 %x, i32 %y) { Modified: llvm/trunk/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2007-09-27-LargeStepping.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \ ; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 13} ; PR1706 Modified: llvm/trunk/test/Analysis/ScalarEvolution/2007-11-18-OrInstruction.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2007-11-18-OrInstruction.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2007-11-18-OrInstruction.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2007-11-18-OrInstruction.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep -e {--> %b} +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | grep -e {--> %b} ; PR1810 define void @fun() { Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-02-11-ReversedCondition.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -scalar-evolution -analyze | grep {Loop header: backedge-taken count is (0 smax %n)} +; RUN: llvm-as < %s | opt -scalar-evolution -analyze -disable-output | grep {Loop header: backedge-taken count is (0 smax %n)} define void @foo(i32 %n) { entry: Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-02-12-SMAXTripCount.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -scalar-evolution -analyze | grep {Loop loop: backedge-taken count is (100 + (-100 smax %n))} +; RUN: llvm-as < %s | opt -scalar-evolution -analyze -disable-output | grep {Loop loop: backedge-taken count is (100 + (-100 smax %n))} ; PR2002 define void @foo(i8 %n) { Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep umax +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | grep umax ; PR2003 define i32 @foo(i32 %n) { Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-05-25-NegativeStepToZero.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \ ; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 61} ; PR2364 Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect1.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& not grep smax +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output |& not grep smax ; PR2261 @lut = common global [256 x i8] zeroinitializer, align 32 ; <[256 x i8]*> [#uses=1] Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-07-12-UnneededSelect2.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& not grep smax +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output |& not grep smax ; PR2070 define i32 @a(i32 %x) nounwind { Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-07-19-InfiniteLoop.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \ ; RUN: -scalar-evolution-max-iterations=0 | grep Unpredictable ; PR2088 Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-07-19-WrappingIV.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \ ; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 113} ; PR2088 Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-11-02-QuadraticCrash.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output ; PR1827 declare void @use(i32) Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-11-15-CubicOOM.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-11-15-CubicOOM.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-11-15-CubicOOM.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-11-15-CubicOOM.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output ; PR2602 define i32 @a() nounwind { Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-LessThanOrEqual.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output |& \ ; RUN: grep {Loop bb: backedge-taken count is (7 + (-1 \\* %argc))} ; XFAIL: * Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-Stride1.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& grep {/u 3} +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output |& grep {/u 3} define i32 @f(i32 %x) nounwind readnone { entry: Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-11-18-Stride2.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& grep {/u 3} +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output |& grep {/u 3} ; XFAIL: * define i32 @f(i32 %x) nounwind readnone { Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-12-08-FiniteSGE.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep {backedge-taken count is 255} +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | grep {backedge-taken count is 255} ; XFAIL: * define i32 @foo(i32 %x, i32 %y, i32* %lam, i32* %alp) nounwind { Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-12-11-SMaxOverflow.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-12-11-SMaxOverflow.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-12-11-SMaxOverflow.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-12-11-SMaxOverflow.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep {0 smax} +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | grep {0 smax} ; XFAIL: * define i32 @f(i32 %c.idx.val) { Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-12-14-StrideAndSigned.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output |& \ ; RUN: grep {(((-1 \\* %i0) + (100005 smax %i0)) /u 5)} ; XFAIL: * Modified: llvm/trunk/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2008-12-15-DontUseSDiv.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution |& grep {/u 5} +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output |& grep {/u 5} ; XFAIL: * define i8 @foo0(i8 %i0) nounwind { Modified: llvm/trunk/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2009-01-02-SignedNegativeStride.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | not grep {/u -1} +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | not grep {/u -1} ; PR3275 @g_16 = external global i16 ; [#uses=3] Modified: llvm/trunk/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2009-04-22-TruncCast.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep {(trunc i} | not grep ext +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | grep {(trunc i} | not grep ext define i16 @test1(i8 %x) { %A = sext i8 %x to i32 Modified: llvm/trunk/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/2009-05-09-PointerEdgeCount.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep {count is 2} +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | grep {count is 2} ; PR3171 %struct.Foo = type { i32 } Modified: llvm/trunk/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/SolveQuadraticEquation.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \ ; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 100} ; PR1101 Modified: llvm/trunk/test/Analysis/ScalarEvolution/avoid-smax-0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/avoid-smax-0.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/avoid-smax-0.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/avoid-smax-0.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -scalar-evolution -analyze | grep {Loop bb3: backedge-taken count is (-1 + %n)} +; RUN: llvm-as < %s | opt -scalar-evolution -analyze -disable-output | grep {Loop bb3: backedge-taken count is (-1 + %n)} ; We don't want to use a max in the trip count expression in ; this testcase. Modified: llvm/trunk/test/Analysis/ScalarEvolution/do-loop.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/do-loop.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/do-loop.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/do-loop.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep smax +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | grep smax ; PR1614 define i32 @f(i32 %x, i32 %y) { Modified: llvm/trunk/test/Analysis/ScalarEvolution/smax.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/smax.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/smax.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/smax.ll Wed Jun 17 15:56:26 2009 @@ -1,5 +1,5 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep smax | count 2 -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | grep \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | grep smax | count 2 +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | grep \ ; RUN: {%. smax %. smax %.} ; PR1614 Modified: llvm/trunk/test/Analysis/ScalarEvolution/trip-count.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/trip-count.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/trip-count.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/trip-count.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output \ ; RUN: -scalar-evolution-max-iterations=0 | grep {backedge-taken count is 10000} ; PR1101 Modified: llvm/trunk/test/Analysis/ScalarEvolution/trip-count2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/trip-count2.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/trip-count2.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/trip-count2.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -scalar-evolution | \ +; RUN: llvm-as < %s | opt -analyze -scalar-evolution -disable-output | \ ; RUN: grep {backedge-taken count is 4} ; PR1101 Modified: llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll?rev=73633&r1=73632&r2=73633&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll Wed Jun 17 15:56:26 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -iv-users -analyze | grep store +; RUN: llvm-as < %s | opt -iv-users -analyze -disable-output | grep store define fastcc void @foo() nounwind { entry: From edwintorok at gmail.com Wed Jun 17 15:58:11 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 17 Jun 2009 23:58:11 +0300 Subject: [llvm-commits] [PATCH] Attempt to DSE non-local stores In-Reply-To: <4A3939FF.30404@gmail.com> References: <4A3939FF.30404@gmail.com> Message-ID: <4A3958E3.4020902@gmail.com> On 2009-06-17 21:46, T?r?k Edwin wrote: > Hi, > > I realised that DSE wasn't actually deleting stores that were really > dead (no loads/stores from pointer), but only deleted redundant stores ( > when there was a second load/store from same pointer). > > DeadStoreElimination also has a comment :// FIXME: cross-block DSE would > be fun. :) > > The attached patch is a small, incremental improvement: > Please ignore the patch. After discussing with resistor on IRC I realised that I need a reverse Memdep, not a direct MemDep. I'll rethink. Best regards, --Edwin From lhames at gmail.com Wed Jun 17 16:01:21 2009 From: lhames at gmail.com (Lang Hames) Date: Wed, 17 Jun 2009 21:01:21 -0000 Subject: [llvm-commits] [llvm] r73634 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/PreAllocSplitting.cpp lib/CodeGen/RegAllocLinearScan.cpp lib/CodeGen/RegAllocPBQP.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp lib/CodeGen/Spiller.cpp lib/CodeGen/Spiller.h lib/CodeGen/StrongPHIElimination.cpp Message-ID: <200906172101.n5HL1Men005015@zion.cs.uiuc.edu> Author: lhames Date: Wed Jun 17 16:01:20 2009 New Revision: 73634 URL: http://llvm.org/viewvc/llvm-project?rev=73634&view=rev Log: VNInfo cleanup. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/lib/CodeGen/Spiller.cpp llvm/trunk/lib/CodeGen/Spiller.h llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=73634&r1=73633&r2=73634&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Wed Jun 17 16:01:20 2009 @@ -33,26 +33,106 @@ class TargetRegisterInfo; struct LiveInterval; - /// VNInfo - If the value number definition is undefined (e.g. phi - /// merge point), it contains ~0u,x. If the value number is not in use, it - /// contains ~1u,x to indicate that the value # is not used. - /// def - Instruction # of the definition. - /// - or reg # of the definition if it's a stack slot liveinterval. - /// copy - Copy iff val# is defined by a copy; zero otherwise. - /// hasPHIKill - One or more of the kills are PHI nodes. - /// redefByEC - Re-defined by early clobber somewhere during the live range. - /// kills - Instruction # of the kills. - struct VNInfo { + /// VNInfo - Value Number Information. + /// This class holds information about a machine level values, including + /// definition and use points. + /// + /// Care must be taken in interpreting the def index of the value. The + /// following rules apply: + /// + /// If the isDefAccurate() method returns false then the def index does not + /// actually point to the defining MachineInstr, or even (necessarily) a + /// valid MachineInstr at all. In general such a def index should not be + /// used as an index to obtain a MachineInstr. The exception is Values + /// defined by PHI instructions, after PHI elimination has occured. In this + /// case the def should point to the start of the block in which the PHI + /// existed. This fact can be used to insert code dealing with the PHI value + /// at the merge point (e.g. to spill or split it). + + class VNInfo { + private: + static const uint8_t HAS_PHI_KILL = 1, + REDEF_BY_EC = 1 << 1, + IS_PHI_DEF = 1 << 2, + IS_UNUSED = 1 << 3, + IS_DEF_ACCURATE = 1 << 4; + + uint8_t flags; + + public: + /// The ID number of this value. unsigned id; + + /// The index of the defining instruction (if isDefAccurate() returns true). unsigned def; MachineInstr *copy; - bool hasPHIKill : 1; - bool redefByEC : 1; SmallVector kills; + VNInfo() - : id(~1U), def(~1U), copy(0), hasPHIKill(false), redefByEC(false) {} + : flags(IS_UNUSED), id(~1U), def(0), copy(0) {} + + /// VNInfo constructor. + /// d is presumed to point to the actual defining instr. If it doesn't + /// setIsDefAccurate(false) should be called after construction. VNInfo(unsigned i, unsigned d, MachineInstr *c) - : id(i), def(d), copy(c), hasPHIKill(false), redefByEC(false) {} + : flags(IS_DEF_ACCURATE), id(i), def(d), copy(c) {} + + /// VNInfo construtor, copies values from orig, except for the value number. + VNInfo(unsigned i, const VNInfo &orig) + : flags(orig.flags), id(i), def(orig.def), copy(orig.copy), + kills(orig.kills) {} + + /// Used for copying value number info. + unsigned getFlags() const { return flags; } + void setFlags(unsigned flags) { this->flags = flags; } + + /// Returns true if one or more kills are PHI nodes. + bool hasPHIKill() const { return flags & HAS_PHI_KILL; } + void setHasPHIKill(bool hasKill) { + if (hasKill) + flags |= HAS_PHI_KILL; + else + flags &= ~HAS_PHI_KILL; + } + + /// Returns true if this value is re-defined by an early clobber somewhere + /// during the live range. + bool hasRedefByEC() const { return flags & REDEF_BY_EC; } + void setHasRedefByEC(bool hasRedef) { + if (hasRedef) + flags |= REDEF_BY_EC; + else + flags &= ~REDEF_BY_EC; + } + + /// Returns true if this value is defined by a PHI instruction (or was, + /// PHI instrucions may have been eliminated). + bool isPHIDef() const { return flags & IS_PHI_DEF; } + void setIsPHIDef(bool phiDef) { + if (phiDef) + flags |= IS_PHI_DEF; + else + flags &= ~IS_PHI_DEF; + } + + /// Returns true if this value is unused. + bool isUnused() const { return flags & IS_UNUSED; } + void setIsUnused(bool unused) { + if (unused) + flags |= IS_UNUSED; + else + flags &= ~IS_UNUSED; + } + + /// Returns true if the def is accurate. + bool isDefAccurate() const { return flags & IS_DEF_ACCURATE; } + void setIsDefAccurate(bool defAccurate) { + if (defAccurate) + flags |= IS_DEF_ACCURATE; + else + flags &= ~IS_DEF_ACCURATE; + } + }; /// LiveRange structure - This represents a simple register range in the @@ -210,15 +290,17 @@ void copyValNumInfo(VNInfo *DstValNo, const VNInfo *SrcValNo) { DstValNo->def = SrcValNo->def; DstValNo->copy = SrcValNo->copy; - DstValNo->hasPHIKill = SrcValNo->hasPHIKill; - DstValNo->redefByEC = SrcValNo->redefByEC; + DstValNo->setFlags(SrcValNo->getFlags()); DstValNo->kills = SrcValNo->kills; } /// getNextValue - Create a new value number and return it. MIIdx specifies /// the instruction that defines the value number. VNInfo *getNextValue(unsigned MIIdx, MachineInstr *CopyMI, - BumpPtrAllocator &VNInfoAllocator) { + bool isDefAccurate, BumpPtrAllocator &VNInfoAllocator) { + + assert(MIIdx != ~0u && MIIdx != ~1u && + "PHI def / unused flags should now be passed explicitly."); #ifdef __GNUC__ unsigned Alignment = (unsigned)__alignof__(VNInfo); #else @@ -229,6 +311,26 @@ static_cast(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo), Alignment)); new (VNI) VNInfo((unsigned)valnos.size(), MIIdx, CopyMI); + VNI->setIsDefAccurate(isDefAccurate); + valnos.push_back(VNI); + return VNI; + } + + /// Create a copy of the given value. The new value will be identical except + /// for the Value number. + VNInfo *createValueCopy(const VNInfo *orig, BumpPtrAllocator &VNInfoAllocator) { + +#ifdef __GNUC__ + unsigned Alignment = (unsigned)__alignof__(VNInfo); +#else + // FIXME: ugly. + unsigned Alignment = 8; +#endif + VNInfo *VNI = + static_cast(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo), + Alignment)); + + new (VNI) VNInfo((unsigned)valnos.size(), *orig); valnos.push_back(VNI); return VNI; } Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=73634&r1=73633&r2=73634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Wed Jun 17 16:01:20 2009 @@ -306,9 +306,9 @@ VNInfo *VNI = valnos.back(); valnos.pop_back(); VNI->~VNInfo(); - } while (!valnos.empty() && valnos.back()->def == ~1U); + } while (!valnos.empty() && valnos.back()->isUnused()); } else { - ValNo->def = ~1U; + ValNo->setIsUnused(true); } } } @@ -354,9 +354,9 @@ VNInfo *VNI = valnos.back(); valnos.pop_back(); VNI->~VNInfo(); - } while (!valnos.empty() && valnos.back()->def == ~1U); + } while (!valnos.empty() && valnos.back()->isUnused()); } else { - ValNo->def = ~1U; + ValNo->setIsUnused(true); } } @@ -372,9 +372,8 @@ // Scale VNI info. for (vni_iterator VNI = vni_begin(), VNIE = vni_end(); VNI != VNIE; ++VNI) { VNInfo *vni = *VNI; - if (vni->def != ~0U && vni->def != ~1U) { - vni->def = InstrSlots::scale(vni->def, factor); - } + + vni->def = InstrSlots::scale(vni->def, factor); for (unsigned i = 0; i < vni->kills.size(); ++i) { if (vni->kills[i] != 0) @@ -593,9 +592,9 @@ VNInfo *VNI = valnos.back(); valnos.pop_back(); VNI->~VNInfo(); - } while (!valnos.empty() && valnos.back()->def == ~1U); + } while (!valnos.empty() && valnos.back()->isUnused()); } else { - V1->def = ~1U; + V1->setIsUnused(true); } } } @@ -622,7 +621,7 @@ else if (UnusedValNo) ClobberValNo = UnusedValNo; else { - UnusedValNo = ClobberValNo = getNextValue(~0U, 0, VNInfoAllocator); + UnusedValNo = ClobberValNo = getNextValue(0, 0, false, VNInfoAllocator); ValNoMaps.insert(std::make_pair(I->valno, ClobberValNo)); } @@ -675,7 +674,7 @@ BumpPtrAllocator &VNInfoAllocator) { // Find a value # to use for the clobber ranges. If there is already a value# // for unknown values, use it. - VNInfo *ClobberValNo = getNextValue(~0U, 0, VNInfoAllocator); + VNInfo *ClobberValNo = getNextValue(0, 0, false, VNInfoAllocator); iterator IP = begin(); IP = std::upper_bound(IP, end(), Start); @@ -758,9 +757,9 @@ VNInfo *VNI = valnos.back(); valnos.pop_back(); VNI->~VNInfo(); - } while (valnos.back()->def == ~1U); + } while (valnos.back()->isUnused()); } else { - V1->def = ~1U; + V1->setIsUnused(true); } return V2; @@ -777,8 +776,7 @@ weight = RHS.weight; for (unsigned i = 0, e = RHS.getNumValNums(); i != e; ++i) { const VNInfo *VNI = RHS.getValNumInfo(i); - VNInfo *NewVNI = getNextValue(~0U, 0, VNInfoAllocator); - copyValNumInfo(NewVNI, VNI); + createValueCopy(VNI, VNInfoAllocator); } for (unsigned i = 0, e = RHS.ranges.size(); i != e; ++i) { const LiveRange &LR = RHS.ranges[i]; @@ -830,22 +828,22 @@ const VNInfo *vni = *i; if (vnum) OS << " "; OS << vnum << "@"; - if (vni->def == ~1U) { + if (vni->isUnused()) { OS << "x"; } else { - if (vni->def == ~0U) + if (!vni->isDefAccurate()) OS << "?"; else OS << vni->def; unsigned ee = vni->kills.size(); - if (ee || vni->hasPHIKill) { + if (ee || vni->hasPHIKill()) { OS << "-("; for (unsigned j = 0; j != ee; ++j) { OS << vni->kills[j]; if (j != ee-1) OS << " "; } - if (vni->hasPHIKill) { + if (vni->hasPHIKill()) { if (ee) OS << " "; OS << "phi"; Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=73634&r1=73633&r2=73634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Jun 17 16:01:20 2009 @@ -199,7 +199,7 @@ // Remap the VNInfo def index, which works the same as the // start indices above. VN's with special sentinel defs // don't need to be remapped. - if (vni->def != ~0U && vni->def != ~1U) { + if (vni->isDefAccurate() && !vni->isUnused()) { unsigned index = vni->def / InstrSlots::NUM; unsigned offset = vni->def % InstrSlots::NUM; if (offset == InstrSlots::LOAD) { @@ -447,7 +447,7 @@ tii_->isMoveInstr(*mi, SrcReg, DstReg, SrcSubReg, DstSubReg)) CopyMI = mi; // Earlyclobbers move back one. - ValNo = interval.getNextValue(defIndex, CopyMI, VNInfoAllocator); + ValNo = interval.getNextValue(defIndex, CopyMI, true, VNInfoAllocator); assert(ValNo->id == 0 && "First value in interval is not 0?"); @@ -539,13 +539,15 @@ // The new value number (#1) is defined by the instruction we claimed // defined value #0. VNInfo *ValNo = interval.getNextValue(OldValNo->def, OldValNo->copy, + false, // update at * VNInfoAllocator); - + ValNo->setFlags(OldValNo->getFlags()); // * <- updating here + // Value#0 is now defined by the 2-addr instruction. OldValNo->def = RedefIndex; OldValNo->copy = 0; if (MO.isEarlyClobber()) - OldValNo->redefByEC = true; + OldValNo->setHasRedefByEC(true); // Add the new live interval which replaces the range for the input copy. LiveRange LR(DefIndex, RedefIndex, ValNo); @@ -577,12 +579,13 @@ DOUT << " Removing [" << Start << "," << End << "] from: "; interval.print(DOUT, tri_); DOUT << "\n"; interval.removeRange(Start, End); - VNI->hasPHIKill = true; + VNI->setHasPHIKill(true); DOUT << " RESULT: "; interval.print(DOUT, tri_); // Replace the interval with one of a NEW value number. Note that this // value number isn't actually defined by an instruction, weird huh? :) - LiveRange LR(Start, End, interval.getNextValue(~0, 0, VNInfoAllocator)); + LiveRange LR(Start, End, interval.getNextValue(0, 0, false, VNInfoAllocator)); + LR.valno->setIsPHIDef(true); DOUT << " replace range with " << LR; interval.addRange(LR); interval.addKill(LR.valno, End); @@ -604,13 +607,13 @@ mi->getOpcode() == TargetInstrInfo::SUBREG_TO_REG || tii_->isMoveInstr(*mi, SrcReg, DstReg, SrcSubReg, DstSubReg)) CopyMI = mi; - ValNo = interval.getNextValue(defIndex, CopyMI, VNInfoAllocator); + ValNo = interval.getNextValue(defIndex, CopyMI, true, VNInfoAllocator); unsigned killIndex = getMBBEndIdx(mbb) + 1; LiveRange LR(defIndex, killIndex, ValNo); interval.addRange(LR); interval.addKill(ValNo, killIndex); - ValNo->hasPHIKill = true; + ValNo->setHasPHIKill(true); DOUT << " +" << LR; } } @@ -692,9 +695,9 @@ LiveInterval::iterator OldLR = interval.FindLiveRangeContaining(start); bool Extend = OldLR != interval.end(); VNInfo *ValNo = Extend - ? OldLR->valno : interval.getNextValue(start, CopyMI, VNInfoAllocator); + ? OldLR->valno : interval.getNextValue(start, CopyMI, true, VNInfoAllocator); if (MO.isEarlyClobber() && Extend) - ValNo->redefByEC = true; + ValNo->setHasRedefByEC(true); LiveRange LR(start, end, ValNo); interval.addRange(LR); interval.addKill(LR.valno, end); @@ -783,7 +786,7 @@ } } - LiveRange LR(start, end, interval.getNextValue(~0U, 0, VNInfoAllocator)); + LiveRange LR(start, end, interval.getNextValue(0, 0, false, VNInfoAllocator)); interval.addRange(LR); interval.addKill(LR.valno, end); DOUT << " +" << LR << '\n'; @@ -1099,13 +1102,12 @@ for (LiveInterval::const_vni_iterator i = li.vni_begin(), e = li.vni_end(); i != e; ++i) { const VNInfo *VNI = *i; - unsigned DefIdx = VNI->def; - if (DefIdx == ~1U) + if (VNI->isUnused()) continue; // Dead val#. // Is the def for the val# rematerializable? - if (DefIdx == ~0u) + if (!VNI->isDefAccurate()) return false; - MachineInstr *ReMatDefMI = getInstructionFromIndex(DefIdx); + MachineInstr *ReMatDefMI = getInstructionFromIndex(VNI->def); bool DefIsLoad = false; if (!ReMatDefMI || !isReMaterializable(li, VNI, ReMatDefMI, SpillIs, DefIsLoad)) @@ -1450,7 +1452,7 @@ if (HasUse) { if (CreatedNewVReg) { LiveRange LR(getLoadIndex(index), getUseIndex(index)+1, - nI.getNextValue(~0U, 0, VNInfoAllocator)); + nI.getNextValue(0, 0, false, VNInfoAllocator)); DOUT << " +" << LR; nI.addRange(LR); } else { @@ -1464,7 +1466,7 @@ } if (HasDef) { LiveRange LR(getDefIndex(index), getStoreIndex(index), - nI.getNextValue(~0U, 0, VNInfoAllocator)); + nI.getNextValue(0, 0, false, VNInfoAllocator)); DOUT << " +" << LR; nI.addRange(LR); } @@ -1840,14 +1842,14 @@ unsigned index = getInstructionIndex(MI); if (HasUse) { LiveRange LR(getLoadIndex(index), getUseIndex(index), - nI.getNextValue(~0U, 0, getVNInfoAllocator())); + nI.getNextValue(0, 0, false, getVNInfoAllocator())); DOUT << " +" << LR; nI.addRange(LR); vrm.addRestorePoint(NewVReg, MI); } if (HasDef) { LiveRange LR(getDefIndex(index), getStoreIndex(index), - nI.getNextValue(~0U, 0, getVNInfoAllocator())); + nI.getNextValue(0, 0, false, getVNInfoAllocator())); DOUT << " +" << LR; nI.addRange(LR); vrm.addSpillPoint(NewVReg, true, MI); @@ -1961,12 +1963,11 @@ i != e; ++i) { const VNInfo *VNI = *i; unsigned VN = VNI->id; - unsigned DefIdx = VNI->def; - if (DefIdx == ~1U) + if (VNI->isUnused()) continue; // Dead val#. // Is the def for the val# rematerializable? - MachineInstr *ReMatDefMI = (DefIdx == ~0u) - ? 0 : getInstructionFromIndex(DefIdx); + MachineInstr *ReMatDefMI = VNI->isDefAccurate() + ? getInstructionFromIndex(VNI->def) : 0; bool dummy; if (ReMatDefMI && isReMaterializable(li, VNI, ReMatDefMI, SpillIs, dummy)) { // Remember how to remat the def of this val#. @@ -1977,7 +1978,7 @@ ReMatDefs[VN] = Clone; bool CanDelete = true; - if (VNI->hasPHIKill) { + if (VNI->hasPHIKill()) { // A kill is a phi node, not all of its uses can be rematerialized. // It must not be deleted. CanDelete = false; @@ -2287,8 +2288,8 @@ LiveInterval& Interval = getOrCreateInterval(reg); VNInfo* VN = Interval.getNextValue( getInstructionIndex(startInst) + InstrSlots::DEF, - startInst, getVNInfoAllocator()); - VN->hasPHIKill = true; + startInst, true, getVNInfoAllocator()); + VN->setHasPHIKill(true); VN->kills.push_back(getMBBEndIdx(startInst->getParent())); LiveRange LR(getInstructionIndex(startInst) + InstrSlots::DEF, getMBBEndIdx(startInst->getParent()) + 1, VN); Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=73634&r1=73633&r2=73634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Wed Jun 17 16:01:20 2009 @@ -343,7 +343,7 @@ if (CurrSLI->hasAtLeastOneValue()) CurrSValNo = CurrSLI->getValNumInfo(0); else - CurrSValNo = CurrSLI->getNextValue(~0U, 0, LSs->getVNInfoAllocator()); + CurrSValNo = CurrSLI->getNextValue(0, 0, false, LSs->getVNInfoAllocator()); return SS; } @@ -637,8 +637,9 @@ if (Phis.count(MBB)) return Phis[MBB]; unsigned StartIndex = LIs->getMBBStartIdx(MBB); - VNInfo *RetVNI = Phis[MBB] = LI->getNextValue(~0U, /*FIXME*/ 0, - LIs->getVNInfoAllocator()); + VNInfo *RetVNI = Phis[MBB] = + LI->getNextValue(0, /*FIXME*/ 0, false, LIs->getVNInfoAllocator()); + if (!IsIntraBlock) LiveOut[MBB] = RetVNI; // If there are no uses or defs between our starting point and the @@ -654,7 +655,7 @@ IncomingVNs[*PI] = Incoming; } - if (MBB->pred_size() == 1 && !RetVNI->hasPHIKill) { + if (MBB->pred_size() == 1 && !RetVNI->hasPHIKill()) { VNInfo* OldVN = RetVNI; VNInfo* NewVN = IncomingVNs.begin()->second; VNInfo* MergedVN = LI->MergeValueNumberInto(OldVN, NewVN); @@ -678,7 +679,7 @@ // VNInfo to represent the joined value. for (DenseMap::iterator I = IncomingVNs.begin(), E = IncomingVNs.end(); I != E; ++I) { - I->second->hasPHIKill = true; + I->second->setHasPHIKill(true); unsigned KillIndex = LIs->getMBBEndIdx(I->first); if (!LiveInterval::isKill(I->second, KillIndex)) LI->addKill(I->second, KillIndex); @@ -730,7 +731,9 @@ unsigned DefIdx = LIs->getInstructionIndex(&*DI); DefIdx = LiveIntervals::getDefIndex(DefIdx); - VNInfo* NewVN = LI->getNextValue(DefIdx, 0, Alloc); + assert(DI->getOpcode() != TargetInstrInfo::PHI && + "Following NewVN isPHIDef flag incorrect. Fix me!"); + VNInfo* NewVN = LI->getNextValue(DefIdx, 0, true, Alloc); // If the def is a move, set the copy field. unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx; @@ -793,7 +796,7 @@ // Bail out if we ever encounter a valno that has a PHI kill. We can't // renumber these. - if (OldVN->hasPHIKill) return; + if (OldVN->hasPHIKill()) return; VNsToCopy.push_back(OldVN); @@ -823,9 +826,7 @@ VNInfo* OldVN = *OI; // Copy the valno over - VNInfo* NewVN = NewLI.getNextValue(OldVN->def, OldVN->copy, - LIs->getVNInfoAllocator()); - NewLI.copyValNumInfo(NewVN, OldVN); + VNInfo* NewVN = NewLI.createValueCopy(OldVN, LIs->getVNInfoAllocator()); NewLI.MergeValueInAsValue(*CurrLI, OldVN, NewVN); // Remove the valno from the old interval @@ -873,7 +874,7 @@ MachineBasicBlock::iterator KillPt = BarrierMBB->end(); unsigned KillIdx = 0; - if (ValNo->def == ~0U || DefMI->getParent() == BarrierMBB) + if (!ValNo->isDefAccurate() || DefMI->getParent() == BarrierMBB) KillPt = findSpillPoint(BarrierMBB, Barrier, NULL, RefsInMBB, KillIdx); else KillPt = findNextEmptySlot(DefMI->getParent(), DefMI, KillIdx); @@ -942,7 +943,7 @@ if (CurrSLI->hasAtLeastOneValue()) CurrSValNo = CurrSLI->getValNumInfo(0); else - CurrSValNo = CurrSLI->getNextValue(~0U, 0, LSs->getVNInfoAllocator()); + CurrSValNo = CurrSLI->getNextValue(0, 0, false, LSs->getVNInfoAllocator()); } return FMI; @@ -1032,13 +1033,13 @@ CurrLI->FindLiveRangeContaining(LIs->getUseIndex(BarrierIdx)); VNInfo *ValNo = LR->valno; - if (ValNo->def == ~1U) { + if (ValNo->isUnused()) { // Defined by a dead def? How can this be? assert(0 && "Val# is defined by a dead def?"); abort(); } - MachineInstr *DefMI = (ValNo->def != ~0U) + MachineInstr *DefMI = ValNo->isDefAccurate() ? LIs->getInstructionFromIndex(ValNo->def) : NULL; // If this would create a new join point, do not split. @@ -1072,8 +1073,8 @@ unsigned SpillIndex = 0; MachineInstr *SpillMI = NULL; int SS = -1; - if (ValNo->def == ~0U) { - // If it's defined by a phi, we must split just before the barrier. + if (!ValNo->isDefAccurate()) { + // If we don't know where the def is we must split just before the barrier. if ((SpillMI = FoldSpill(LI->reg, RC, 0, Barrier, BarrierMBB, SS, RefsInMBB))) { SpillIndex = LIs->getInstructionIndex(SpillMI); @@ -1254,17 +1255,16 @@ // We don't currently try to handle definitions with PHI kills, because // it would involve processing more than one VNInfo at once. - if (CurrVN->hasPHIKill) continue; + if (CurrVN->hasPHIKill()) continue; // We also don't try to handle the results of PHI joins, since there's // no defining instruction to analyze. - unsigned DefIdx = CurrVN->def; - if (DefIdx == ~0U || DefIdx == ~1U) continue; + if (!CurrVN->isDefAccurate() || CurrVN->isUnused()) continue; // We're only interested in eliminating cruft introduced by the splitter, // is of the form load-use or load-use-store. First, check that the // definition is a load, and remember what stack slot we loaded it from. - MachineInstr* DefMI = LIs->getInstructionFromIndex(DefIdx); + MachineInstr* DefMI = LIs->getInstructionFromIndex(CurrVN->def); int FrameIndex; if (!TII->isLoadFromStackSlot(DefMI, FrameIndex)) continue; @@ -1383,7 +1383,7 @@ if (DefMBB == BarrierMBB) return false; - if (LR->valno->hasPHIKill) + if (LR->valno->hasPHIKill()) return false; unsigned MBBEnd = LIs->getMBBEndIdx(BarrierMBB); Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=73634&r1=73633&r2=73634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Wed Jun 17 16:01:20 2009 @@ -358,7 +358,7 @@ return Reg; VNInfo *vni = cur.begin()->valno; - if (!vni->def || vni->def == ~1U || vni->def == ~0U) + if (!vni->def || vni->isUnused() || !vni->isDefAccurate()) return Reg; MachineInstr *CopyMI = li_->getInstructionFromIndex(vni->def); unsigned SrcReg, DstReg, SrcSubReg, DstSubReg, PhysReg; @@ -745,7 +745,7 @@ if (SI.hasAtLeastOneValue()) VNI = SI.getValNumInfo(0); else - VNI = SI.getNextValue(~0U, 0, ls_->getVNInfoAllocator()); + VNI = SI.getNextValue(0, 0, false, ls_->getVNInfoAllocator()); LiveInterval &RI = li_->getInterval(cur->reg); // FIXME: This may be overly conservative. @@ -921,7 +921,7 @@ // one, e.g. X86::mov32to32_. These move instructions are not coalescable. if (!vrm_->getRegAllocPref(cur->reg) && cur->hasAtLeastOneValue()) { VNInfo *vni = cur->begin()->valno; - if (vni->def && vni->def != ~1U && vni->def != ~0U) { + if (vni->def && !vni->isUnused() && vni->isDefAccurate()) { MachineInstr *CopyMI = li_->getInstructionFromIndex(vni->def); unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; if (CopyMI && Modified: llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp?rev=73634&r1=73633&r2=73634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocPBQP.cpp Wed Jun 17 16:01:20 2009 @@ -651,7 +651,7 @@ if (stackInterval.getNumValNums() != 0) vni = stackInterval.getValNumInfo(0); else - vni = stackInterval.getNextValue(-0U, 0, lss->getVNInfoAllocator()); + vni = stackInterval.getNextValue(0, 0, false, lss->getVNInfoAllocator()); LiveInterval &rhsInterval = lis->getInterval(spilled->reg); stackInterval.MergeRangesInAsValue(rhsInterval, vni); Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=73634&r1=73633&r2=73634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Wed Jun 17 16:01:20 2009 @@ -141,7 +141,7 @@ // The live interval of ECX is represented as this: // %reg20,inf = [46,47:1)[174,230:0) 0 at 174-(230) 1 at 46-(47) // The coalescer has no idea there was a def in the middle of [174,230]. - if (AValNo->redefByEC) + if (AValNo->hasRedefByEC()) return false; // If AValNo is defined as a copy from IntB, we can potentially process this. @@ -203,7 +203,8 @@ for (const unsigned *SR = tri_->getSubRegisters(IntB.reg); *SR; ++SR) { LiveInterval &SRLI = li_->getInterval(*SR); SRLI.addRange(LiveRange(FillerStart, FillerEnd, - SRLI.getNextValue(FillerStart, 0, li_->getVNInfoAllocator()))); + SRLI.getNextValue(FillerStart, 0, true, + li_->getVNInfoAllocator()))); } } @@ -304,8 +305,10 @@ assert(ALR != IntA.end() && "Live range not found!"); VNInfo *AValNo = ALR->valno; // If other defs can reach uses of this def, then it's not safe to perform - // the optimization. - if (AValNo->def == ~0U || AValNo->def == ~1U || AValNo->hasPHIKill) + // the optimization. FIXME: Do isPHIDef and isDefAccurate both need to be + // tested? + if (AValNo->isPHIDef() || !AValNo->isDefAccurate() || + AValNo->isUnused() || AValNo->hasPHIKill()) return false; MachineInstr *DefMI = li_->getInstructionFromIndex(AValNo->def); const TargetInstrDesc &TID = DefMI->getDesc(); @@ -351,7 +354,7 @@ unsigned OpIdx = NewMI->findRegisterUseOperandIdx(IntA.reg, false); NewMI->getOperand(OpIdx).setIsKill(); - bool BHasPHIKill = BValNo->hasPHIKill; + bool BHasPHIKill = BValNo->hasPHIKill(); SmallVector BDeadValNos; SmallVector BKills; std::map BExtend; @@ -403,7 +406,7 @@ // extended to the end of the existing live range defined by the copy. unsigned DefIdx = li_->getDefIndex(UseIdx); const LiveRange *DLR = IntB.getLiveRangeContaining(DefIdx); - BHasPHIKill |= DLR->valno->hasPHIKill; + BHasPHIKill |= DLR->valno->hasPHIKill(); assert(DLR->valno->def == DefIdx); BDeadValNos.push_back(DLR->valno); BExtend[DLR->start] = DLR->end; @@ -462,7 +465,7 @@ } } IntB.addKills(ValNo, BKills); - ValNo->hasPHIKill = BHasPHIKill; + ValNo->setHasPHIKill(BHasPHIKill); DOUT << " result = "; IntB.print(DOUT, tri_); DOUT << "\n"; @@ -578,8 +581,10 @@ assert(SrcLR != SrcInt.end() && "Live range not found!"); VNInfo *ValNo = SrcLR->valno; // If other defs can reach uses of this def, then it's not safe to perform - // the optimization. - if (ValNo->def == ~0U || ValNo->def == ~1U || ValNo->hasPHIKill) + // the optimization. FIXME: Do isPHIDef and isDefAccurate both need to be + // tested? + if (ValNo->isPHIDef() || !ValNo->isDefAccurate() || + ValNo->isUnused() || ValNo->hasPHIKill()) return false; MachineInstr *DefMI = li_->getInstructionFromIndex(ValNo->def); const TargetInstrDesc &TID = DefMI->getDesc(); @@ -671,7 +676,7 @@ return false; unsigned KillIdx = li_->getMBBEndIdx(MBB) + 1; if (DstLR->valno->kills.size() == 1 && - DstLR->valno->kills[0] == KillIdx && DstLR->valno->hasPHIKill) + DstLR->valno->kills[0] == KillIdx && DstLR->valno->hasPHIKill()) return true; return false; } @@ -935,7 +940,7 @@ LiveInterval::iterator LR = li.FindLiveRangeContaining(CopyIdx); if (LR == li.end()) return false; - if (LR->valno->hasPHIKill) + if (LR->valno->hasPHIKill()) return false; if (LR->valno->def != CopyIdx) return false; @@ -1682,9 +1687,9 @@ E = SavedLI->vni_end(); I != E; ++I) { const VNInfo *ValNo = *I; VNInfo *NewValNo = RealInt.getNextValue(ValNo->def, ValNo->copy, + false, // updated at * li_->getVNInfoAllocator()); - NewValNo->hasPHIKill = ValNo->hasPHIKill; - NewValNo->redefByEC = ValNo->redefByEC; + NewValNo->setFlags(ValNo->getFlags()); // * updated here. RealInt.addKills(NewValNo, ValNo->kills); RealInt.MergeValueInAsValue(*SavedLI, ValNo, NewValNo); } @@ -1723,7 +1728,8 @@ for (LiveInterval::const_vni_iterator i = ResSrcInt->vni_begin(), e = ResSrcInt->vni_end(); i != e; ++i) { const VNInfo *vni = *i; - if (!vni->def || vni->def == ~1U || vni->def == ~0U) + // FIXME: Do isPHIDef and isDefAccurate both need to be tested? + if (!vni->def || vni->isUnused() || vni->isPHIDef() || !vni->isDefAccurate()) continue; MachineInstr *CopyMI = li_->getInstructionFromIndex(vni->def); unsigned NewSrcReg, NewDstReg, NewSrcSubIdx, NewDstSubIdx; @@ -1870,7 +1876,8 @@ unsigned SrcReg = li_->getVNInfoSourceReg(LR->valno); if (SrcReg == Reg) return true; - if (LR->valno->def == ~0U && + // FIXME: Do isPHIDef and isDefAccurate both need to be tested? + if ((LR->valno->isPHIDef() || !LR->valno->isDefAccurate()) && TargetRegisterInfo::isPhysicalRegister(li.reg) && *tri_->getSuperRegisters(li.reg)) { // It's a sub-register live interval, we may not have precise information. @@ -2039,7 +2046,8 @@ // Okay, the final step is to loop over the RHS live intervals, adding them to // the LHS. - LHSValNo->hasPHIKill |= VNI->hasPHIKill; + if (VNI->hasPHIKill()) + LHSValNo->setHasPHIKill(true); LHS.addKills(LHSValNo, VNI->kills); LHS.MergeRangesInAsValue(RHS, LHSValNo); LHS.weight += RHS.weight; @@ -2206,7 +2214,7 @@ for (LiveInterval::vni_iterator i = LHS.vni_begin(), e = LHS.vni_end(); i != e; ++i) { VNInfo *VNI = *i; - if (VNI->def == ~1U || VNI->copy == 0) // Src not defined by a copy? + if (VNI->isUnused() || VNI->copy == 0) // Src not defined by a copy? continue; // DstReg is known to be a register in the LHS interval. If the src is @@ -2223,7 +2231,7 @@ for (LiveInterval::vni_iterator i = RHS.vni_begin(), e = RHS.vni_end(); i != e; ++i) { VNInfo *VNI = *i; - if (VNI->def == ~1U || VNI->copy == 0) // Src not defined by a copy? + if (VNI->isUnused() || VNI->copy == 0) // Src not defined by a copy? continue; // DstReg is known to be a register in the RHS interval. If the src is @@ -2243,7 +2251,7 @@ i != e; ++i) { VNInfo *VNI = *i; unsigned VN = VNI->id; - if (LHSValNoAssignments[VN] >= 0 || VNI->def == ~1U) + if (LHSValNoAssignments[VN] >= 0 || VNI->isUnused()) continue; ComputeUltimateVN(VNI, NewVNInfo, LHSValsDefinedFromRHS, RHSValsDefinedFromLHS, @@ -2253,7 +2261,7 @@ i != e; ++i) { VNInfo *VNI = *i; unsigned VN = VNI->id; - if (RHSValNoAssignments[VN] >= 0 || VNI->def == ~1U) + if (RHSValNoAssignments[VN] >= 0 || VNI->isUnused()) continue; // If this value number isn't a copy from the LHS, it's a new number. if (RHSValsDefinedFromLHS.find(VNI) == RHSValsDefinedFromLHS.end()) { @@ -2317,7 +2325,8 @@ VNInfo *VNI = I->first; unsigned LHSValID = LHSValNoAssignments[VNI->id]; LiveInterval::removeKill(NewVNInfo[LHSValID], VNI->def); - NewVNInfo[LHSValID]->hasPHIKill |= VNI->hasPHIKill; + if (VNI->hasPHIKill()) + NewVNInfo[LHSValID]->setHasPHIKill(true); RHS.addKills(NewVNInfo[LHSValID], VNI->kills); } @@ -2327,7 +2336,8 @@ VNInfo *VNI = I->first; unsigned RHSValID = RHSValNoAssignments[VNI->id]; LiveInterval::removeKill(NewVNInfo[RHSValID], VNI->def); - NewVNInfo[RHSValID]->hasPHIKill |= VNI->hasPHIKill; + if (VNI->hasPHIKill()) + NewVNInfo[RHSValID]->setHasPHIKill(true); LHS.addKills(NewVNInfo[RHSValID], VNI->kills); } Modified: llvm/trunk/lib/CodeGen/Spiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.cpp?rev=73634&r1=73633&r2=73634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.cpp (original) +++ llvm/trunk/lib/CodeGen/Spiller.cpp Wed Jun 17 16:01:20 2009 @@ -47,16 +47,24 @@ tii = mf->getTarget().getInstrInfo(); } - /// Insert a store of the given vreg to the given stack slot immediately - /// after the given instruction. Returns the base index of the inserted - /// instruction. The caller is responsible for adding an appropriate - /// LiveInterval to the LiveIntervals analysis. - unsigned insertStoreFor(MachineInstr *mi, unsigned ss, - unsigned newVReg, - const TargetRegisterClass *trc) { - MachineBasicBlock::iterator nextInstItr(mi); - ++nextInstItr; + /// Ensures there is space before the given machine instruction, returns the + /// instruction's new number. + unsigned makeSpaceBefore(MachineInstr *mi) { + if (!lis->hasGapBeforeInstr(lis->getInstructionIndex(mi))) { + lis->scaleNumbering(2); + ls->scaleNumbering(2); + } + + unsigned miIdx = lis->getInstructionIndex(mi); + + assert(lis->hasGapBeforeInstr(miIdx)); + + return miIdx; + } + /// Ensure there is space after the given machine instruction, returns the + /// instruction's new number. + unsigned makeSpaceAfter(MachineInstr *mi) { if (!lis->hasGapAfterInstr(lis->getInstructionIndex(mi))) { lis->scaleNumbering(2); ls->scaleNumbering(2); @@ -66,7 +74,23 @@ assert(lis->hasGapAfterInstr(miIdx)); - tii->storeRegToStackSlot(*mi->getParent(), nextInstItr, newVReg, + return miIdx; + } + + + /// Insert a store of the given vreg to the given stack slot immediately + /// after the given instruction. Returns the base index of the inserted + /// instruction. The caller is responsible for adding an appropriate + /// LiveInterval to the LiveIntervals analysis. + unsigned insertStoreFor(MachineInstr *mi, unsigned ss, + unsigned vreg, + const TargetRegisterClass *trc) { + MachineBasicBlock::iterator nextInstItr(mi); + ++nextInstItr; + + unsigned miIdx = makeSpaceAfter(mi); + + tii->storeRegToStackSlot(*mi->getParent(), nextInstItr, vreg, true, ss, trc); MachineBasicBlock::iterator storeInstItr(mi); ++storeInstItr; @@ -86,20 +110,13 @@ /// instruction. The caller is responsible for adding an appropriate /// LiveInterval to the LiveIntervals analysis. unsigned insertLoadFor(MachineInstr *mi, unsigned ss, - unsigned newVReg, + unsigned vreg, const TargetRegisterClass *trc) { MachineBasicBlock::iterator useInstItr(mi); - - if (!lis->hasGapBeforeInstr(lis->getInstructionIndex(mi))) { - lis->scaleNumbering(2); - ls->scaleNumbering(2); - } - - unsigned miIdx = lis->getInstructionIndex(mi); - - assert(lis->hasGapBeforeInstr(miIdx)); - - tii->loadRegFromStackSlot(*mi->getParent(), useInstItr, newVReg, ss, trc); + + unsigned miIdx = makeSpaceBefore(mi); + + tii->loadRegFromStackSlot(*mi->getParent(), useInstItr, vreg, ss, trc); MachineBasicBlock::iterator loadInstItr(mi); --loadInstItr; MachineInstr *loadInst = &*loadInstItr; @@ -113,7 +130,6 @@ return loadInstIdx; } - /// Add spill ranges for every use/def of the live interval, inserting loads /// immediately before each use, and stores after each def. No folding is /// attempted. @@ -178,7 +194,7 @@ end = lis->getUseIndex(lis->getInstructionIndex(mi)); VNInfo *vni = - newLI->getNextValue(loadInstIdx, 0, lis->getVNInfoAllocator()); + newLI->getNextValue(loadInstIdx, 0, true, lis->getVNInfoAllocator()); vni->kills.push_back(lis->getInstructionIndex(mi)); LiveRange lr(start, end, vni); @@ -191,7 +207,7 @@ end = lis->getUseIndex(storeInstIdx); VNInfo *vni = - newLI->getNextValue(storeInstIdx, 0, lis->getVNInfoAllocator()); + newLI->getNextValue(storeInstIdx, 0, true, lis->getVNInfoAllocator()); vni->kills.push_back(storeInstIdx); LiveRange lr(start, end, vni); @@ -201,7 +217,6 @@ added.push_back(newLI); } - return added; } Modified: llvm/trunk/lib/CodeGen/Spiller.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.h?rev=73634&r1=73633&r2=73634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.h (original) +++ llvm/trunk/lib/CodeGen/Spiller.h Wed Jun 17 16:01:20 2009 @@ -18,6 +18,7 @@ class LiveStacks; class MachineFunction; class VirtRegMap; + class MachineInstr; /// Spiller interface. /// @@ -26,7 +27,11 @@ class Spiller { public: virtual ~Spiller() = 0; + + /// Spill the given live range. The method used will depend on the Spiller + /// implementation selected. virtual std::vector spill(LiveInterval *li) = 0; + }; /// Create and return a spiller object, as specified on the command line. Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=73634&r1=73633&r2=73634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Wed Jun 17 16:01:20 2009 @@ -827,7 +827,7 @@ // Add a live range for the new vreg LiveInterval& Int = LI.getInterval(I->getOperand(i).getReg()); VNInfo* FirstVN = *Int.vni_begin(); - FirstVN->hasPHIKill = false; + FirstVN->setHasPHIKill(false); if (I->getOperand(i).isKill()) FirstVN->kills.push_back( LiveIntervals::getUseIndex(LI.getInstructionIndex(I))); @@ -886,10 +886,7 @@ VNInfo* OldVN = R.valno; VNInfo*& NewVN = VNMap[OldVN]; if (!NewVN) { - NewVN = LHS.getNextValue(OldVN->def, - OldVN->copy, - LI.getVNInfoAllocator()); - NewVN->kills = OldVN->kills; + NewVN = LHS.createValueCopy(OldVN, LI.getVNInfoAllocator()); } LiveRange LR (R.start, R.end, NewVN); @@ -987,7 +984,7 @@ LiveInterval& Int = LI.getOrCreateInterval(I->first); const LiveRange* LR = Int.getLiveRangeContaining(LI.getMBBEndIdx(SI->second)); - LR->valno->hasPHIKill = true; + LR->valno->setHasPHIKill(true); I->second.erase(SI->first); } @@ -1037,7 +1034,7 @@ // now has an unknown def. unsigned idx = LI.getDefIndex(LI.getInstructionIndex(PInstr)); const LiveRange* PLR = PI.getLiveRangeContaining(idx); - PLR->valno->def = ~0U; + PLR->valno->setIsPHIDef(true); LiveRange R (LI.getMBBStartIdx(PInstr->getParent()), PLR->start, PLR->valno); PI.addRange(R); From isanbard at gmail.com Wed Jun 17 16:01:29 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 17 Jun 2009 14:01:29 -0700 Subject: [llvm-commits] [llvm] r73631 - /llvm/trunk/lib/VMCore/Constants.cpp In-Reply-To: <200906172043.n5HKhelC004034@zion.cs.uiuc.edu> References: <200906172043.n5HKhelC004034@zion.cs.uiuc.edu> Message-ID: <16e5fdf90906171401q167e81e9kcfeb27fbf0d16632@mail.gmail.com> Thanks! :-) -bw On Wed, Jun 17, 2009 at 1:43 PM, Owen Anderson wrote: > Author: resistor > Date: Wed Jun 17 15:43:39 2009 > New Revision: 73631 > > URL: http://llvm.org/viewvc/llvm-project?rev=73631&view=rev > Log: > Factor out some common code. > > Modified: > ? ?llvm/trunk/lib/VMCore/Constants.cpp > > Modified: llvm/trunk/lib/VMCore/Constants.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73631&r1=73630&r2=73631&view=diff > > ============================================================================== > --- llvm/trunk/lib/VMCore/Constants.cpp (original) > +++ llvm/trunk/lib/VMCore/Constants.cpp Wed Jun 17 15:43:39 2009 > @@ -1221,6 +1221,34 @@ > ? ? ? } > ? ? ? return I; > ? ? } > + > + ? ?ConstantClass* Create(const TypeClass *Ty, const ValType &V, > + ? ? ? ? ? ? ? ? ? ? ? ? ?typename MapTy::iterator I) { > + ? ? ?ConstantClass* Result = > + ? ? ? ?ConstantCreator::create(Ty, V); > + > + ? ? ?assert(Result->getType() == Ty && "Type specified is not correct!"); > + ? ? ?I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); > + > + ? ? ?if (HasLargeKey) ?// Remember the reverse mapping if needed. > + ? ? ? ?InverseMap.insert(std::make_pair(Result, I)); > + > + ? ? ?// If the type of the constant is abstract, make sure that an entry > + ? ? ?// exists for it in the AbstractTypeMap. > + ? ? ?if (Ty->isAbstract()) { > + ? ? ? ?typename AbstractTypeMapTy::iterator TI = > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? AbstractTypeMap.find(Ty); > + > + ? ? ? ?if (TI == AbstractTypeMap.end()) { > + ? ? ? ? ?// Add ourselves to the ATU list of the type. > + ? ? ? ? ?cast(Ty)->addAbstractTypeUser(this); > + > + ? ? ? ? ?AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); > + ? ? ? ?} > + ? ? ?} > + > + ? ? ?return Result; > + ? ?} > ?public: > > ? ? /// getOrCreate - Return the specified constant from the map, creating it if > @@ -1245,28 +1273,7 @@ > ? ? ? ? ? ? Result = static_cast(I->second); > ? ? ? ? ? if (!Result) { > ? ? ? ? ? ? // If no preexisting value, create one now... > - ? ? ? ? ? ?Result = > - ? ? ? ? ? ? ?ConstantCreator::create(Ty, V); > - > - ? ? ? ? ? ?assert(Result->getType() == Ty && "Type specified is not correct!"); > - ? ? ? ? ? ?I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); > - > - ? ? ? ? ? ?if (HasLargeKey) ?// Remember the reverse mapping if needed. > - ? ? ? ? ? ? ?InverseMap.insert(std::make_pair(Result, I)); > - > - ? ? ? ? ? ?// If the type of the constant is abstract, make sure that an entry > - ? ? ? ? ? ?// exists for it in the AbstractTypeMap. > - ? ? ? ? ? ?if (Ty->isAbstract()) { > - ? ? ? ? ? ? ?typename AbstractTypeMapTy::iterator TI = > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? AbstractTypeMap.find(Ty); > - > - ? ? ? ? ? ? ?if (TI == AbstractTypeMap.end()) { > - ? ? ? ? ? ? ? ?// Add ourselves to the ATU list of the type. > - ? ? ? ? ? ? ? ?cast(Ty)->addAbstractTypeUser(this); > - > - ? ? ? ? ? ? ? ?AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); > - ? ? ? ? ? ? ?} > - ? ? ? ? ? ?} > + ? ? ? ? ? ?Result = Create(Ty, V, I); > ? ? ? ? ? } > ? ? ? ? } > > @@ -1278,28 +1285,7 @@ > ? ? ? ? ? return static_cast(I->second); > > ? ? ? ? // If no preexisting value, create one now... > - ? ? ? ?ConstantClass *Result = > - ? ? ? ? ?ConstantCreator::create(Ty, V); > - > - ? ? ? ?assert(Result->getType() == Ty && "Type specified is not correct!"); > - ? ? ? ?I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); > - > - ? ? ? ?if (HasLargeKey) ?// Remember the reverse mapping if needed. > - ? ? ? ? ?InverseMap.insert(std::make_pair(Result, I)); > - > - ? ? ? ?// If the type of the constant is abstract, make sure that an entry > - ? ? ? ?// exists for it in the AbstractTypeMap. > - ? ? ? ?if (Ty->isAbstract()) { > - ? ? ? ? ?typename AbstractTypeMapTy::iterator TI = AbstractTypeMap.find(Ty); > - > - ? ? ? ? ?if (TI == AbstractTypeMap.end()) { > - ? ? ? ? ? ?// Add ourselves to the ATU list of the type. > - ? ? ? ? ? ?cast(Ty)->addAbstractTypeUser(this); > - > - ? ? ? ? ? ?AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); > - ? ? ? ? ?} > - ? ? ? ?} > - ? ? ? ?return Result; > + ? ? ? ?return Create(Ty, V, I); > ? ? ? } > ? ? } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From stefanus.dutoit at rapidmind.com Wed Jun 17 16:12:32 2009 From: stefanus.dutoit at rapidmind.com (Stefanus Du Toit) Date: Wed, 17 Jun 2009 21:12:32 -0000 Subject: [llvm-commits] [llvm] r73635 - /llvm/trunk/docs/ProgrammersManual.html Message-ID: <200906172112.n5HLCZVN005418@zion.cs.uiuc.edu> Author: sdt Date: Wed Jun 17 16:12:26 2009 New Revision: 73635 URL: http://llvm.org/viewvc/llvm-project?rev=73635&view=rev Log: Fix link to BasicBlock doxygen documentation in Programmer's Manual Modified: llvm/trunk/docs/ProgrammersManual.html Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=73635&r1=73634&r2=73635&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Wed Jun 17 16:12:26 2009 @@ -3558,7 +3558,7 @@

    #include "llvm/BasicBlock.h"
    -doxygen info: BasicBlock +doxygen info: BasicBlock Class
    Superclass: Value

    From resistor at mac.com Wed Jun 17 16:16:28 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 21:16:28 -0000 Subject: [llvm-commits] [llvm] r73636 - /llvm/trunk/lib/VMCore/Pass.cpp Message-ID: <200906172116.n5HLGSsF005548@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 16:16:20 2009 New Revision: 73636 URL: http://llvm.org/viewvc/llvm-project?rev=73636&view=rev Log: We need to use double-checked locking for lazy initialization in this case when running multithreaded. Modified: llvm/trunk/lib/VMCore/Pass.cpp Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=73636&r1=73635&r2=73636&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Wed Jun 17 16:16:20 2009 @@ -19,6 +19,8 @@ #include "llvm/ModuleProvider.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/Threading.h" +#include "llvm/System/Atomic.h" #include #include #include @@ -192,8 +194,20 @@ // ressurection after llvm_shutdown is run. static PassRegistrar *getPassRegistrar() { static PassRegistrar *PassRegistrarObj = 0; + + // Use double-checked locking to safely initialize the registrar when + // we're running in multithreaded mode. if (!PassRegistrarObj) - PassRegistrarObj = new PassRegistrar(); + if (llvm_is_multithreaded()) { + llvm_acquire_global_lock(); + if (!PassRegistrarObj) { + PassRegistrar* tmp = new PassRegistrar(); + sys::MemoryFence(); + PassRegistrarObj = tmp; + } + llvm_release_global_lock(); + } else + PassRegistrarObj = new PassRegistrar(); return PassRegistrarObj; } From bob.wilson at apple.com Wed Jun 17 16:17:40 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 17 Jun 2009 14:17:40 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r73532 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h In-Reply-To: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> References: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> Message-ID: <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> Anton, This patch is causing a number of regressions for ARM. The compiler runs OK but the results are not correct. For example, the SingleSource/Benchmarks/Shootout/strcat.c test ends up with most of its code incorrectly optimized away. Both llc and cbe tests fail, but it passes without optimization. Please investigate. I'm going to revert this change for now. On Jun 16, 2009, at 11:53 AM, Anton Korobeynikov wrote: > Author: asl > Date: Tue Jun 16 13:53:48 2009 > New Revision: 73532 > > URL: http://llvm.org/viewvc/llvm-project?rev=73532&view=rev > Log: > Generate new ARM calling conventions depending on options, etc. > > Added: > llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h > Modified: > llvm-gcc-4.2/trunk/gcc/config/arm/arm.h > > Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=73532&r1=73531&r2=73532&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) > +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Tue Jun 16 13:53:48 2009 > @@ -36,6 +36,15 @@ > #endif > /* LLVM LOCAL end */ > #endif > + > +/* LLVM LOCAL begin */ > +#ifdef ENABLE_LLVM > +/* Add general target specific stuff */ > +#include "llvm-arm-target.h" > + > +#endif /* ENABLE_LLVM */ > +/* LLVM LOCAL end */ > + > /* APPLE LOCAL end ARM darwin target */ > > /* APPLE LOCAL ARM interworking */ > > Added: 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=73532&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h (added) > +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Tue Jun 16 > 13:53:48 2009 > @@ -0,0 +1,36 @@ > +/* LLVM LOCAL begin (ENTIRE FILE!) */ > +#ifdef ENABLE_LLVM > +/* Some target-specific hooks for gcc->llvm conversion > +Copyright (C) 2009 Free Software Foundation, Inc. > +Contributed by Anton Korobeynikov (asl at math.spbu.ru) > + > +This file is part of GCC. > + > +GCC is free software; you can redistribute it and/or modify it under > +the terms of the GNU General Public License as published by the Free > +Software Foundation; either version 2, or (at your option) any later > +version. > + > +GCC is distributed in the hope that it will be useful, but WITHOUT > ANY > +WARRANTY; without even the implied warranty of MERCHANTABILITY or > +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License > +for more details. > + > +You should have received a copy of the GNU General Public License > +along with GCC; see the file COPYING. If not, write to the Free > +Software Foundation, 59 Temple Place - Suite 330, Boston, MA > +02111-1307, USA. */ > + > +/* LLVM specific stuff for supporting calling convention output */ > +#define TARGET_ADJUST_LLVM_CC(CC, type) \ > + { \ > + if (TARGET_AAPCS_BASED) \ > + CC = (TARGET_VFP && TARGET_HARD_FLOAT_ABI ? \ > + CallingConv::ARM_AAPCS_VFP : \ > + CallingConv::ARM_AAPCS); \ > + else \ > + CC = CallingConv::ARM_APCS; \ > + } > + > +#endif /* ENABLE_LLVM */ > +/* LLVM LOCAL end (ENTIRE FILE!) */ > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From bob.wilson at apple.com Wed Jun 17 16:19:41 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 17 Jun 2009 21:19:41 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73638 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h Message-ID: <200906172119.n5HLJfbN005679@zion.cs.uiuc.edu> Author: bwilson Date: Wed Jun 17 16:19:40 2009 New Revision: 73638 URL: http://llvm.org/viewvc/llvm-project?rev=73638&view=rev Log: Revert 73532. Author: asl Date: Tue Jun 16 13:53:48 2009 New Revision: 73532 URL: http://llvm.org/viewvc/llvm-project?rev=73532&view=rev Log: Generate new ARM calling conventions depending on options, etc. Removed: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=73638&r1=73637&r2=73638&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Wed Jun 17 16:19:40 2009 @@ -36,15 +36,6 @@ #endif /* LLVM LOCAL end */ #endif - -/* LLVM LOCAL begin */ -#ifdef ENABLE_LLVM -/* Add general target specific stuff */ -#include "llvm-arm-target.h" - -#endif /* ENABLE_LLVM */ -/* LLVM LOCAL end */ - /* APPLE LOCAL end ARM darwin target */ /* APPLE LOCAL ARM interworking */ Removed: 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=73637&view=auto ============================================================================== --- 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 (removed) @@ -1,36 +0,0 @@ -/* LLVM LOCAL begin (ENTIRE FILE!) */ -#ifdef ENABLE_LLVM -/* Some target-specific hooks for gcc->llvm conversion -Copyright (C) 2009 Free Software Foundation, Inc. -Contributed by Anton Korobeynikov (asl at math.spbu.ru) - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ - -/* LLVM specific stuff for supporting calling convention output */ -#define TARGET_ADJUST_LLVM_CC(CC, type) \ - { \ - if (TARGET_AAPCS_BASED) \ - CC = (TARGET_VFP && TARGET_HARD_FLOAT_ABI ? \ - CallingConv::ARM_AAPCS_VFP : \ - CallingConv::ARM_AAPCS); \ - else \ - CC = CallingConv::ARM_APCS; \ - } - -#endif /* ENABLE_LLVM */ -/* LLVM LOCAL end (ENTIRE FILE!) */ From anton at korobeynikov.info Wed Jun 17 16:22:07 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 18 Jun 2009 01:22:07 +0400 Subject: [llvm-commits] [llvm-gcc-4.2] r73532 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h In-Reply-To: <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> References: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> Message-ID: Hi Bob > This patch is causing a number of regressions for ARM. ?The compiler > runs OK but the results are not correct. ?For example, the > SingleSource/Benchmarks/Shootout/strcat.c test ends up with most of > its code incorrectly optimized away. ?Both llc and cbe tests fail, but > it passes without optimization. ?Please investigate. ?I'm going to > revert this change for now. That's pretty strange since calling convention should not influence optimizers at all. Could you please provide me the LLVM IR with and without optimizations? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From resistor at mac.com Wed Jun 17 16:28:54 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 21:28:54 -0000 Subject: [llvm-commits] [llvm] r73639 - /llvm/trunk/lib/VMCore/PassManager.cpp Message-ID: <200906172128.n5HLStZ0005981@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 16:28:54 2009 New Revision: 73639 URL: http://llvm.org/viewvc/llvm-project?rev=73639&view=rev Log: Guard mutation of the timing info global. Modified: llvm/trunk/lib/VMCore/PassManager.cpp Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=73639&r1=73638&r2=73639&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Wed Jun 17 16:28:54 2009 @@ -20,6 +20,8 @@ #include "llvm/Support/Streams.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Threading.h" +#include "llvm/System/Mutex.h" #include "llvm/Analysis/Dominators.h" #include "llvm-c/Core.h" #include @@ -355,6 +357,9 @@ /// amount of time each pass takes to execute. This only happens when /// -time-passes is enabled on the command line. /// + +static ManagedStatic TimingInfoMutex; + class VISIBILITY_HIDDEN TimingInfo { std::map TimingData; TimerGroup TG; @@ -379,18 +384,22 @@ if (dynamic_cast(P)) return; + if (llvm_is_multithreaded()) TimingInfoMutex->acquire(); std::map::iterator I = TimingData.find(P); if (I == TimingData.end()) I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first; I->second.startTimer(); + if (llvm_is_multithreaded()) TimingInfoMutex->release(); } void passEnded(Pass *P) { if (dynamic_cast(P)) return; + if (llvm_is_multithreaded()) TimingInfoMutex->acquire(); std::map::iterator I = TimingData.find(P); assert(I != TimingData.end() && "passStarted/passEnded not nested right!"); I->second.stopTimer(); + if (llvm_is_multithreaded()) TimingInfoMutex->release(); } }; From anton at korobeynikov.info Wed Jun 17 16:34:13 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 18 Jun 2009 01:34:13 +0400 Subject: [llvm-commits] [llvm-gcc-4.2] r73532 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h In-Reply-To: <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> References: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> Message-ID: Hi, Bob > This patch is causing a number of regressions for ARM. ?The compiler > runs OK but the results are not correct. ?For example, the > SingleSource/Benchmarks/Shootout/strcat.c test ends up with most of > its code incorrectly optimized away. ?Both llc and cbe tests fail, but > it passes without optimization. ?Please investigate. ?I'm going to > revert this change for now. This seems to be a bug in the simplifycfg pass. It inserts bogus unreachable instructions. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From evan.cheng at apple.com Wed Jun 17 16:50:32 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 17 Jun 2009 14:50:32 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r73532 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h In-Reply-To: References: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> Message-ID: <605E726A-5B87-4E39-B66C-F1651F14BE1D@apple.com> Looks like some passes are confused about the new calling convention info? I see something like this: define cc66 i32 @main(i32 %argc, i8** %argv) nounwind { ^^^^ Evan On Jun 17, 2009, at 2:22 PM, Anton Korobeynikov wrote: > Hi Bob > >> This patch is causing a number of regressions for ARM. The compiler >> runs OK but the results are not correct. For example, the >> SingleSource/Benchmarks/Shootout/strcat.c test ends up with most of >> its code incorrectly optimized away. Both llc and cbe tests fail, >> but >> it passes without optimization. Please investigate. I'm going to >> revert this change for now. > That's pretty strange since calling convention should not influence > optimizers at all. Could you please provide me the LLVM IR with and > without optimizations? > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State > University > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From bob.wilson at apple.com Wed Jun 17 16:53:22 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 17 Jun 2009 14:53:22 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r73532 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h In-Reply-To: References: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> Message-ID: <145BADF4-D4B4-42D5-AB4E-1DF7A7500462@apple.com> On Jun 17, 2009, at 2:22 PM, Anton Korobeynikov wrote: > Hi Bob > >> This patch is causing a number of regressions for ARM. The compiler >> runs OK but the results are not correct. For example, the >> SingleSource/Benchmarks/Shootout/strcat.c test ends up with most of >> its code incorrectly optimized away. Both llc and cbe tests fail, >> but >> it passes without optimization. Please investigate. I'm going to >> revert this change for now. > That's pretty strange since calling convention should not influence > optimizers at all. Could you please provide me the LLVM IR with and > without optimizations? I'm afraid I already overwrote the files. It sounds like you've already found the problem in simplifycfg. I certainly agree that it is strange. From resistor at mac.com Wed Jun 17 16:56:06 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 21:56:06 -0000 Subject: [llvm-commits] [llvm] r73642 - /llvm/trunk/lib/VMCore/LeakDetector.cpp Message-ID: <200906172156.n5HLu6D0007026@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 16:56:05 2009 New Revision: 73642 URL: http://llvm.org/viewvc/llvm-project?rev=73642&view=rev Log: Thread-safe (and ManagedStatic-ized) LeakDetector! Modified: llvm/trunk/lib/VMCore/LeakDetector.cpp Modified: llvm/trunk/lib/VMCore/LeakDetector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LeakDetector.cpp?rev=73642&r1=73641&r2=73642&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LeakDetector.cpp (original) +++ llvm/trunk/lib/VMCore/LeakDetector.cpp Wed Jun 17 16:56:05 2009 @@ -14,7 +14,10 @@ #include "llvm/Support/LeakDetector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Streams.h" +#include "llvm/Support/Threading.h" +#include "llvm/System/RWMutex.h" #include "llvm/Value.h" using namespace llvm; @@ -29,33 +32,63 @@ static void print(const Value* P) { cerr << *P; } }; + ManagedStatic LeakDetectorLock; + template struct VISIBILITY_HIDDEN LeakDetectorImpl { - explicit LeakDetectorImpl(const char* const name) : Cache(0), Name(name) { } + explicit LeakDetectorImpl(const char* const name = "") : + Cache(0), Name(name) { } + void clear() { + Cache = 0; + Ts.clear(); + } + + void setName(const char* n) { + Name = n; + } + // Because the most common usage pattern, by far, is to add a // garbage object, then remove it immediately, we optimize this // case. When an object is added, it is not added to the set // immediately, it is added to the CachedValue Value. If it is // immediately removed, no set search need be performed. void addGarbage(const T* o) { - if (Cache) { - assert(Ts.count(Cache) == 0 && "Object already in set!"); - Ts.insert(Cache); + if (llvm_is_multithreaded()) { + sys::ScopedWriter Writer(&*LeakDetectorLock); + if (Cache) { + assert(Ts.count(Cache) == 0 && "Object already in set!"); + Ts.insert(Cache); + } + Cache = o; + } else { + if (Cache) { + assert(Ts.count(Cache) == 0 && "Object already in set!"); + Ts.insert(Cache); + } + Cache = o; } - Cache = o; } void removeGarbage(const T* o) { - if (o == Cache) - Cache = 0; // Cache hit - else - Ts.erase(o); + if (llvm_is_multithreaded()) { + sys::ScopedWriter Writer(&*LeakDetectorLock); + if (o == Cache) + Cache = 0; // Cache hit + else + Ts.erase(o); + } else { + if (o == Cache) + Cache = 0; // Cache hit + else + Ts.erase(o); + } } bool hasGarbage(const std::string& Message) { addGarbage(0); // Flush the Cache + if (llvm_is_multithreaded()) LeakDetectorLock->reader_acquire(); assert(Cache == 0 && "No value should be cached anymore!"); if (!Ts.empty()) { @@ -68,60 +101,52 @@ } cerr << '\n'; + if (llvm_is_multithreaded()) LeakDetectorLock->reader_release(); return true; } + + if (llvm_is_multithreaded()) LeakDetectorLock->reader_release(); return false; } private: SmallPtrSet Ts; const T* Cache; - const char* const Name; + const char* Name; }; - static LeakDetectorImpl *Objects; - static LeakDetectorImpl *LLVMObjects; - - static LeakDetectorImpl &getObjects() { - if (Objects == 0) - Objects = new LeakDetectorImpl("GENERIC"); - return *Objects; - } - - static LeakDetectorImpl &getLLVMObjects() { - if (LLVMObjects == 0) - LLVMObjects = new LeakDetectorImpl("LLVM"); - return *LLVMObjects; - } + static ManagedStatic > Objects; + static ManagedStatic > LLVMObjects; static void clearGarbage() { - delete Objects; - delete LLVMObjects; - Objects = 0; - LLVMObjects = 0; + Objects->clear(); + LLVMObjects->clear(); } } void LeakDetector::addGarbageObjectImpl(void *Object) { - getObjects().addGarbage(Object); + Objects->addGarbage(Object); } void LeakDetector::addGarbageObjectImpl(const Value *Object) { - getLLVMObjects().addGarbage(Object); + LLVMObjects->addGarbage(Object); } void LeakDetector::removeGarbageObjectImpl(void *Object) { - getObjects().removeGarbage(Object); + Objects->removeGarbage(Object); } void LeakDetector::removeGarbageObjectImpl(const Value *Object) { - getLLVMObjects().removeGarbage(Object); + LLVMObjects->removeGarbage(Object); } void LeakDetector::checkForGarbageImpl(const std::string &Message) { + Objects->setName("GENERIC"); + LLVMObjects->setName("LLVM"); + // use non-short-circuit version so that both checks are performed - if (getObjects().hasGarbage(Message) | - getLLVMObjects().hasGarbage(Message)) + if (Objects->hasGarbage(Message) | + LLVMObjects->hasGarbage(Message)) cerr << "\nThis is probably because you removed an object, but didn't " << "delete it. Please check your code for memory leaks.\n"; From anton at korobeynikov.info Wed Jun 17 16:56:05 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 18 Jun 2009 01:56:05 +0400 Subject: [llvm-commits] [llvm-gcc-4.2] r73532 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h In-Reply-To: <605E726A-5B87-4E39-B66C-F1651F14BE1D@apple.com> References: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> <605E726A-5B87-4E39-B66C-F1651F14BE1D@apple.com> Message-ID: Hello, Evan > Looks like some passes are confused about the new calling convention > info? No. The actualy problem is IRBuilder. It does not honour calling convention during creation of CallInst. Thus, for example, strlen declared with apcs calling conv is being called with C calling conv (after libcall simplification), instcombine turned such call into undef and later simplifycfg cleans all stuff out. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From resistor at mac.com Wed Jun 17 17:01:09 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 22:01:09 -0000 Subject: [llvm-commits] [llvm] r73643 - /llvm/trunk/lib/VMCore/Mangler.cpp Message-ID: <200906172201.n5HM19qJ007208@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 17:01:09 2009 New Revision: 73643 URL: http://llvm.org/viewvc/llvm-project?rev=73643&view=rev Log: Use atomic increment here. Modified: llvm/trunk/lib/VMCore/Mangler.cpp Modified: llvm/trunk/lib/VMCore/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Mangler.cpp?rev=73643&r1=73642&r2=73643&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Mangler.cpp (original) +++ llvm/trunk/lib/VMCore/Mangler.cpp Wed Jun 17 17:01:09 2009 @@ -14,6 +14,7 @@ #include "llvm/Support/Mangler.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" +#include "llvm/System/Atomic.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" @@ -164,8 +165,12 @@ } else if (!GV->hasName()) { // Must mangle the global into a unique ID. unsigned TypeUniqueID = getTypeID(GV->getType()); - static unsigned GlobalID = 0; - Name = "__unnamed_" + utostr(TypeUniqueID) + "_" + utostr(GlobalID++); + static uint32_t GlobalID = 0; + + unsigned OldID = GlobalID; + sys::AtomicIncrement(&GlobalID); + + Name = "__unnamed_" + utostr(TypeUniqueID) + "_" + utostr(OldID); } else { if (GV->hasPrivateLinkage()) Name = makeNameProper(GV->getName() + Suffix, Prefix, PrivatePrefix); From evan.cheng at apple.com Wed Jun 17 17:05:05 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 17 Jun 2009 15:05:05 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r73532 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h In-Reply-To: References: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> <605E726A-5B87-4E39-B66C-F1651F14BE1D@apple.com> Message-ID: Ok, that certainly makes a lot more sense. Evan On Jun 17, 2009, at 2:56 PM, Anton Korobeynikov wrote: > Hello, Evan > >> Looks like some passes are confused about the new calling convention >> info? > No. The actualy problem is IRBuilder. It does not honour calling > convention during creation of CallInst. Thus, for example, strlen > declared with apcs calling conv is being called with C calling conv > (after libcall simplification), instcombine turned such call into > undef and later simplifycfg cleans all stuff out. > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State > University > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Wed Jun 17 17:12:50 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Jun 2009 15:12:50 -0700 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) In-Reply-To: <4A3955A9.4040300@gmail.com> References: <4A393785.8090202@gmail.com> <6C8ECC3B-BE0E-4D05-92B4-926E9FF6CD8B@apple.com> <4A3955A9.4040300@gmail.com> Message-ID: <25637945-0AD3-4F9C-9C96-DB4AB9A4CCC7@apple.com> On Jun 17, 2009, at 1:44 PM, T?r?k Edwin wrote: > On 2009-06-17 23:25, Dan Gohman wrote: > >> On Jun 17, 2009, at 11:35 AM, T?r?k Edwin wrote: >> >> >> >> >> >>> Hi, >>> >>> >>> >>> I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't >>> >>> folded, >>> >>> the attached patch folds this into: >>> >>> umax (zext t1 %X to %t0, zext t1 %Y to %t0). >>> >>> >>> >>> It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext >>> t1 >>> >>> (umax (%X, %Y)) to %t0. >>> >>> >>> >>> zext is very often encountered in SCEV expressions on x86-64, since >>> >>> pointer indexes for GEP are i64. >>> >>> >>> >>> Thoughts? >>> >>> >>> >> >> >> Another question to ask is whether this kind of thing belongs in >> >> ScalarEvolution, or if it would be more appropriate for >> >> instcombine. Instcombine looks at all instructions in a program, >> >> while ScalarEvolution typically only looks at those related to >> >> loop iteration. Also, instcombine could more easily handle more >> >> generalized cases of this optimization, for example with umin. >> >> >> >> On the other hand, there are cases where it makes sense to do >> >> such simplifications in ScalarEvolution. Can you given an >> >> example where you're seeing this kind of code? >> >> >> > > It doesn't have much to do with code generation/optimization, but > rather > with analysis. > I have a pass that tries to find buffer overflow bugs, doing that > involves lots of umax() expressions. > If I can move the zext out of umax I can decide quite early that an > access is valid: > > int foo(unsigned n, unsigned i) > { > char *a = malloc(n); > if (!a) > return -1; > if (i < n) > a[i]=0; > } Where does the umax come from in this code? I guess that you're transforming it in some way; could you show what the code looks like after the transformation? Thanks, Dan From asl at math.spbu.ru Wed Jun 17 17:20:46 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Wed, 17 Jun 2009 22:20:46 -0000 Subject: [llvm-commits] [llvm] r73646 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> Author: asl Date: Wed Jun 17 17:20:46 2009 New Revision: 73646 URL: http://llvm.org/viewvc/llvm-project?rev=73646&view=rev Log: Honour calling convention and attributes of Callee by default. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=73646&r1=73645&r2=73646&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Jun 17 17:20:46 2009 @@ -17,6 +17,7 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" +#include "llvm/GlobalAlias.h" #include "llvm/GlobalVariable.h" #include "llvm/Function.h" #include "llvm/Support/ConstantFolder.h" @@ -586,32 +587,49 @@ return Insert(PHINode::Create(Ty), Name); } + CallInst *TransferAttributes(CallInst *CI, const Value* Callee) const { + if (const GlobalAlias *GA = dyn_cast(Callee)) + Callee = GA->getAliasedGlobal(); + + if (const Function *F = dyn_cast(Callee)) { + CI->setCallingConv(F->getCallingConv()); + CI->setAttributes(F->getAttributes()); + } + + return CI; + } + CallInst *CreateCall(Value *Callee, const char *Name = "") { - return Insert(CallInst::Create(Callee), Name); + return Insert(TransferAttributes(CallInst::Create(Callee), Callee), Name); } CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") { - return Insert(CallInst::Create(Callee, Arg), Name); + return Insert(TransferAttributes(CallInst::Create(Callee, Arg), + Callee), Name); } CallInst *CreateCall2(Value *Callee, Value *Arg1, Value *Arg2, const char *Name = "") { Value *Args[] = { Arg1, Arg2 }; - return Insert(CallInst::Create(Callee, Args, Args+2), Name); + return Insert(TransferAttributes(CallInst::Create(Callee, Args, Args+2), + Callee), Name); } CallInst *CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, const char *Name = "") { Value *Args[] = { Arg1, Arg2, Arg3 }; - return Insert(CallInst::Create(Callee, Args, Args+3), Name); + return Insert(TransferAttributes(CallInst::Create(Callee, Args, Args+3), + Callee), Name); } CallInst *CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, Value *Arg4, const char *Name = "") { Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; - return Insert(CallInst::Create(Callee, Args, Args+4), Name); + return Insert(TransferAttributes(CallInst::Create(Callee, Args, Args+4), + Callee), Name); } template CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, InputIterator ArgEnd, const char *Name = "") { - return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd), Name); + return Insert(TransferAttributes(CallInst::Create(Callee, ArgBegin, ArgEnd), + Callee), Name); } Value *CreateSelect(Value *C, Value *True, Value *False, From anton at korobeynikov.info Wed Jun 17 17:22:46 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 18 Jun 2009 02:22:46 +0400 Subject: [llvm-commits] [llvm-gcc-4.2] r73532 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h In-Reply-To: <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> References: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> Message-ID: Hi Bob > This patch is causing a number of regressions for ARM. ?The compiler > runs OK but the results are not correct. ?For example, the > SingleSource/Benchmarks/Shootout/strcat.c test ends up with most of > its code incorrectly optimized away. ?Both llc and cbe tests fail, but > it passes without optimization. ?Please investigate. ?I'm going to > revert this change for now. Could you please to reapply stuff after r73646 landed and check once again? It should fix the problems you've seen. Thanks! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From resistor at mac.com Wed Jun 17 17:23:31 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 22:23:31 -0000 Subject: [llvm-commits] [llvm] r73647 - in /llvm/trunk: include/llvm/System/RWMutex.h lib/VMCore/Function.cpp Message-ID: <200906172223.n5HMNVfu007920@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 17:23:31 2009 New Revision: 73647 URL: http://llvm.org/viewvc/llvm-project?rev=73647&view=rev Log: Protect the GC table in Function.cpp Modified: llvm/trunk/include/llvm/System/RWMutex.h llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/include/llvm/System/RWMutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/RWMutex.h?rev=73647&r1=73646&r2=73647&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/RWMutex.h (original) +++ llvm/trunk/include/llvm/System/RWMutex.h Wed Jun 17 17:23:31 2009 @@ -79,6 +79,20 @@ /// @} }; + /// ScopedReader - RAII acquisition of a writer lock + struct ScopedReader { + RWMutex* mutex; + + explicit ScopedReader(RWMutex* m) { + mutex = m; + mutex->reader_acquire(); + } + + ~ScopedReader() { + mutex->reader_release(); + } + }; + /// ScopedWriter - RAII acquisition of a writer lock struct ScopedWriter { RWMutex* mutex; Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=73647&r1=73646&r2=73647&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Wed Jun 17 17:23:31 2009 @@ -16,7 +16,9 @@ #include "llvm/IntrinsicInst.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Support/LeakDetector.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/StringPool.h" +#include "llvm/System/RWMutex.h" #include "SymbolTableListTraitsImpl.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringExtras.h" @@ -228,38 +230,42 @@ // allocating an additional word in Function for programs which do not use GC // (i.e., most programs) at the cost of increased overhead for clients which do // use GC. -static DenseMap *GCNames; -static StringPool *GCNamePool; +static ManagedStatic > GCNames; +static ManagedStatic GCNamePool; +static ManagedStatic GCLock; bool Function::hasGC() const { - return GCNames && GCNames->count(this); + if (llvm_is_multithreaded()) { + sys::ScopedReader Reader(&*GCLock); + return GCNames->count(this); + } else + return GCNames->count(this); } const char *Function::getGC() const { assert(hasGC() && "Function has no collector"); - return *(*GCNames)[this]; + + if (llvm_is_multithreaded()) { + sys::ScopedReader Reader(&*GCLock); + return *(*GCNames)[this]; + } else + return *(*GCNames)[this]; } void Function::setGC(const char *Str) { - if (!GCNamePool) - GCNamePool = new StringPool(); - if (!GCNames) - GCNames = new DenseMap(); - (*GCNames)[this] = GCNamePool->intern(Str); + if (llvm_is_multithreaded()) { + sys::ScopedWriter Writer(&*GCLock); + (*GCNames)[this] = GCNamePool->intern(Str); + } else + (*GCNames)[this] = GCNamePool->intern(Str); } void Function::clearGC() { - if (GCNames) { + if (llvm_is_multithreaded()) { + sys::ScopedWriter Writer(&*GCLock); + GCNames->erase(this); + } else GCNames->erase(this); - if (GCNames->empty()) { - delete GCNames; - GCNames = 0; - if (GCNamePool->empty()) { - delete GCNamePool; - GCNamePool = 0; - } - } - } } /// copyAttributesFrom - copy all additional attributes (those not needed to From isanbard at gmail.com Wed Jun 17 17:40:51 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 17 Jun 2009 15:40:51 -0700 Subject: [llvm-commits] [llvm] r73646 - /llvm/trunk/include/llvm/Support/IRBuilder.h In-Reply-To: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> References: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> Message-ID: <16e5fdf90906171540l57f0a039l27ca8055b06e7d7a@mail.gmail.com> Hi Anton, This might be causing this failure on Darwin: Running /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/build/llvm.src/test/FrontendC/dg.exp ... FAIL: /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/build/llvm.src/test/FrontendC/2007-09-20-GcrootAttribute.c Failed with exit(1) at line 1 while running: /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/build/llvm-gcc.install/bin/llvm-gcc -m32 -fstrict-aliasing -Wstrict-aliasing -I/usr/include/c++/4.0.0/i686-apple-darwin9 -I/usr/include/c++/4.0.0 -emit-llvm -w -S -emit-llvm /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/build/llvm.src/test/FrontendC/2007-09-20-GcrootAttribute.c -o - | /usr/bin/grep llvm.gcroot call void @llvm.gcroot(i8** %2, i8* null) nounwind declare void @llvm.gcroot(i8**, i8*) nounwind call void @llvm.gcroot(i8** %1, i8* null) nounwind call void @llvm.gcroot(i8** %2, i8* null) nounwind call void @llvm.gcroot(i8** %3, i8* null) nounwind call void @llvm.gcroot(i8** %4, i8* null) nounwind Assertion failed: (InternTable.empty() && "PooledStringPtr leaked!"), function ~StringPool, file /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/build/llvm.src/lib/Support/StringPool.cpp, line 22. /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/build/llvm.src/test/FrontendC/2007-09-20-GcrootAttribute.c:29: internal compiler error: Abort trap Please submit a full bug report, with preprocessed source if appropriate. See for instructions. Could you check? :-) -bw On Wed, Jun 17, 2009 at 3:20 PM, Anton Korobeynikov wrote: > Author: asl > Date: Wed Jun 17 17:20:46 2009 > New Revision: 73646 > > URL: http://llvm.org/viewvc/llvm-project?rev=73646&view=rev > Log: > Honour calling convention and attributes of Callee by default. > > Modified: > ? ?llvm/trunk/include/llvm/Support/IRBuilder.h > > Modified: llvm/trunk/include/llvm/Support/IRBuilder.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=73646&r1=73645&r2=73646&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) > +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Jun 17 17:20:46 2009 > @@ -17,6 +17,7 @@ > > ?#include "llvm/Constants.h" > ?#include "llvm/Instructions.h" > +#include "llvm/GlobalAlias.h" > ?#include "llvm/GlobalVariable.h" > ?#include "llvm/Function.h" > ?#include "llvm/Support/ConstantFolder.h" > @@ -586,32 +587,49 @@ > ? ? return Insert(PHINode::Create(Ty), Name); > ? } > > + ?CallInst *TransferAttributes(CallInst *CI, const Value* Callee) const { > + ? ?if (const GlobalAlias *GA = dyn_cast(Callee)) > + ? ? ?Callee = GA->getAliasedGlobal(); > + > + ? ?if (const Function *F = dyn_cast(Callee)) { > + ? ? ?CI->setCallingConv(F->getCallingConv()); > + ? ? ?CI->setAttributes(F->getAttributes()); > + ? ?} > + > + ? ?return CI; > + ?} > + > ? CallInst *CreateCall(Value *Callee, const char *Name = "") { > - ? ?return Insert(CallInst::Create(Callee), Name); > + ? ?return Insert(TransferAttributes(CallInst::Create(Callee), Callee), Name); > ? } > ? CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") { > - ? ?return Insert(CallInst::Create(Callee, Arg), Name); > + ? ?return Insert(TransferAttributes(CallInst::Create(Callee, Arg), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Callee), Name); > ? } > ? CallInst *CreateCall2(Value *Callee, Value *Arg1, Value *Arg2, > ? ? ? ? ? ? ? ? ? ? ? ? const char *Name = "") { > ? ? Value *Args[] = { Arg1, Arg2 }; > - ? ?return Insert(CallInst::Create(Callee, Args, Args+2), Name); > + ? ?return Insert(TransferAttributes(CallInst::Create(Callee, Args, Args+2), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Callee), Name); > ? } > ? CallInst *CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, > ? ? ? ? ? ? ? ? ? ? ? ? const char *Name = "") { > ? ? Value *Args[] = { Arg1, Arg2, Arg3 }; > - ? ?return Insert(CallInst::Create(Callee, Args, Args+3), Name); > + ? ?return Insert(TransferAttributes(CallInst::Create(Callee, Args, Args+3), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Callee), Name); > ? } > ? CallInst *CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, > ? ? ? ? ? ? ? ? ? ? ? ? Value *Arg4, const char *Name = "") { > ? ? Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; > - ? ?return Insert(CallInst::Create(Callee, Args, Args+4), Name); > + ? ?return Insert(TransferAttributes(CallInst::Create(Callee, Args, Args+4), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Callee), Name); > ? } > > ? template > ? CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, > ? ? ? ? ? ? ? ? ? ? ? ?InputIterator ArgEnd, const char *Name = "") { > - ? ?return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd), Name); > + ? ?return Insert(TransferAttributes(CallInst::Create(Callee, ArgBegin, ArgEnd), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Callee), Name); > ? } > > ? Value *CreateSelect(Value *C, Value *True, Value *False, > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From anton at korobeynikov.info Wed Jun 17 17:48:21 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 18 Jun 2009 02:48:21 +0400 Subject: [llvm-commits] [llvm] r73646 - /llvm/trunk/include/llvm/Support/IRBuilder.h In-Reply-To: <16e5fdf90906171540l57f0a039l27ca8055b06e7d7a@mail.gmail.com> References: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> <16e5fdf90906171540l57f0a039l27ca8055b06e7d7a@mail.gmail.com> Message-ID: Hi Bill > This might be causing this failure on Darwin: > > Running /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/build/llvm.src/test/FrontendC/dg.exp > ... > FAIL: /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/build/llvm.src/test/FrontendC/2007-09-20-GcrootAttribute.c This might be due to Owen's commit, not mine - he touched GC stuff. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From resistor at mac.com Wed Jun 17 17:53:57 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 22:53:57 -0000 Subject: [llvm-commits] [llvm] r73653 - /llvm/trunk/lib/VMCore/Type.cpp Message-ID: <200906172253.n5HMrvBo009154@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 17:53:57 2009 New Revision: 73653 URL: http://llvm.org/viewvc/llvm-project?rev=73653&view=rev Log: Use double-checked locking for this lazy initialization. Modified: llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73653&r1=73652&r2=73653&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Wed Jun 17 17:53:57 2009 @@ -453,8 +453,27 @@ if (NumContainedTys != 0) { // The type must stay abstract. To do this, we insert a pointer to a type // that will never get resolved, thus will always be abstract. - static Type *AlwaysOpaqueTy = OpaqueType::get(); - static PATypeHolder Holder(AlwaysOpaqueTy); + static Type *AlwaysOpaqueTy = 0; + static PATypeHolder* Holder = 0; + if (!AlwaysOpaqueTy) { + if (llvm_is_multithreaded()) { + llvm_acquire_global_lock(); + + if (!AlwaysOpaqueTy) { + Type *tmp = OpaqueType::get(); + PATypeHolder* tmp2 = new PATypeHolder(AlwaysOpaqueTy); + sys::MemoryFence(); + AlwaysOpaqueTy = tmp; + Holder = tmp2; + } + + llvm_release_global_lock(); + } else { + AlwaysOpaqueTy = OpaqueType::get(); + Holder = new PATypeHolder(AlwaysOpaqueTy); + } + } + ContainedTys[0] = AlwaysOpaqueTy; // Change the rest of the types to be Int32Ty's. It doesn't matter what we From bob.wilson at apple.com Wed Jun 17 17:54:12 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 17 Jun 2009 22:54:12 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73654 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h Message-ID: <200906172254.n5HMsD1k009172@zion.cs.uiuc.edu> Author: bwilson Date: Wed Jun 17 17:54:12 2009 New Revision: 73654 URL: http://llvm.org/viewvc/llvm-project?rev=73654&view=rev Log: Reapply r73532. Added: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=73654&r1=73653&r2=73654&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Wed Jun 17 17:54:12 2009 @@ -36,6 +36,15 @@ #endif /* LLVM LOCAL end */ #endif + +/* LLVM LOCAL begin */ +#ifdef ENABLE_LLVM +/* Add general target specific stuff */ +#include "llvm-arm-target.h" + +#endif /* ENABLE_LLVM */ +/* LLVM LOCAL end */ + /* APPLE LOCAL end ARM darwin target */ /* APPLE LOCAL ARM interworking */ Added: 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=73654&view=auto ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h (added) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Wed Jun 17 17:54:12 2009 @@ -0,0 +1,36 @@ +/* LLVM LOCAL begin (ENTIRE FILE!) */ +#ifdef ENABLE_LLVM +/* Some target-specific hooks for gcc->llvm conversion +Copyright (C) 2009 Free Software Foundation, Inc. +Contributed by Anton Korobeynikov (asl at math.spbu.ru) + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ + +/* LLVM specific stuff for supporting calling convention output */ +#define TARGET_ADJUST_LLVM_CC(CC, type) \ + { \ + if (TARGET_AAPCS_BASED) \ + CC = (TARGET_VFP && TARGET_HARD_FLOAT_ABI ? \ + CallingConv::ARM_AAPCS_VFP : \ + CallingConv::ARM_AAPCS); \ + else \ + CC = CallingConv::ARM_APCS; \ + } + +#endif /* ENABLE_LLVM */ +/* LLVM LOCAL end (ENTIRE FILE!) */ From bob.wilson at apple.com Wed Jun 17 17:55:28 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 17 Jun 2009 15:55:28 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r73532 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.h llvm-arm-target.h In-Reply-To: References: <200906161853.n5GIrmcS002633@zion.cs.uiuc.edu> <981A22B5-3393-4DB6-AF8D-556AF9D2C567@apple.com> Message-ID: On Jun 17, 2009, at 3:22 PM, Anton Korobeynikov wrote: > Hi Bob > >> This patch is causing a number of regressions for ARM. The compiler >> runs OK but the results are not correct. For example, the >> SingleSource/Benchmarks/Shootout/strcat.c test ends up with most of >> its code incorrectly optimized away. Both llc and cbe tests fail, >> but >> it passes without optimization. Please investigate. I'm going to >> revert this change for now. > Could you please to reapply stuff after r73646 landed and check once > again? It should fix the problems you've seen. Done. I verified that the strcat test works now. I'm assuming the other regressions will also be cleared up by this change. It seems likely anyway. From isanbard at gmail.com Wed Jun 17 17:55:35 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 17 Jun 2009 15:55:35 -0700 Subject: [llvm-commits] [llvm] r73646 - /llvm/trunk/include/llvm/Support/IRBuilder.h In-Reply-To: References: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> <16e5fdf90906171540l57f0a039l27ca8055b06e7d7a@mail.gmail.com> Message-ID: <16e5fdf90906171555x2954174bt84d077493b9462d9@mail.gmail.com> On Wed, Jun 17, 2009 at 3:48 PM, Anton Korobeynikov wrote: > Hi Bill > >> This might be causing this failure on Darwin: >> >> Running /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/build/llvm.src/test/FrontendC/dg.exp >> ... >> FAIL: /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/build/llvm.src/test/FrontendC/2007-09-20-GcrootAttribute.c > This might be due to Owen's commit, not mine - he touched GC stuff. > Okay. I'll harass him. :-) -bw From gohman at apple.com Wed Jun 17 18:17:06 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Jun 2009 23:17:06 -0000 Subject: [llvm-commits] [llvm] r73656 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/trunc-mask-ext.ll Message-ID: <200906172317.n5HNH6Ij010142@zion.cs.uiuc.edu> Author: djg Date: Wed Jun 17 18:17:05 2009 New Revision: 73656 URL: http://llvm.org/viewvc/llvm-project?rev=73656&view=rev Log: Instcombine zext(trunc(x) & mask) to x&mask, even if the trunc has multiple users. Added: llvm/trunk/test/Transforms/InstCombine/trunc-mask-ext.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=73656&r1=73655&r2=73656&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed Jun 17 18:17:05 2009 @@ -8564,6 +8564,20 @@ } } + // zext(trunc(t) & C) -> (t & C) if C is a mask. + if (SrcI && SrcI->getOpcode() == Instruction::And && SrcI->hasOneUse()) + if (ConstantInt *C = dyn_cast(SrcI->getOperand(1))) + if (TruncInst *TI = dyn_cast(SrcI->getOperand(0))) { + Value *TI0 = TI->getOperand(0); + if (TI0->getType() == CI.getType()) { + unsigned TO = C->getValue().countTrailingOnes(); + if (APIntOps::isMask(TO, C->getValue())) + return + BinaryOperator::Create(Instruction::And, TI0, + ConstantExpr::getZExt(C, CI.getType())); + } + } + return 0; } Added: llvm/trunk/test/Transforms/InstCombine/trunc-mask-ext.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/trunc-mask-ext.ll?rev=73656&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/trunc-mask-ext.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/trunc-mask-ext.ll Wed Jun 17 18:17:05 2009 @@ -0,0 +1,23 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis > %t +; RUN: not grep zext %t +; RUN: not grep sext %t + +; Instcombine should be able to eliminate both ext casts. + +declare void @use(i32) + +define i64 @foo(i64 %a) { + %b = trunc i64 %a to i32 + %c = and i32 %b, 15 + %d = zext i32 %c to i64 + call void @use(i32 %b) + ret i64 %d +} +define i64 @bar(i64 %a) { + %b = trunc i64 %a to i32 + %c = shl i32 %b, 4 + %q = ashr i32 %c, 4 + %d = sext i32 %q to i64 + call void @use(i32 %b) + ret i64 %d +} From asl at math.spbu.ru Wed Jun 17 18:43:18 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Wed, 17 Jun 2009 23:43:18 -0000 Subject: [llvm-commits] [llvm] r73660 - /llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <200906172343.n5HNhIVm011045@zion.cs.uiuc.edu> Author: asl Date: Wed Jun 17 18:43:18 2009 New Revision: 73660 URL: http://llvm.org/viewvc/llvm-project?rev=73660&view=rev Log: Thumb2 instructions are enabled only in unified assembler mode. Emit switch directive for it. I have no idea whether this is requirement for Darwin or not. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=73660&r1=73659&r2=73660&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Jun 17 18:43:18 2009 @@ -840,6 +840,10 @@ if (Subtarget->isTargetDarwin()) Mang->setUseQuotes(true); + // Thumb-2 instructions are supported only in unified assembler syntax mode. + if (Subtarget->isTargetELF() && Subtarget->hasThumb2()) + O << "\t.syntax unified\n"; + // Emit ARM Build Attributes if (Subtarget->isTargetELF()) { // CPU Type From asl at math.spbu.ru Wed Jun 17 18:43:36 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Wed, 17 Jun 2009 23:43:36 -0000 Subject: [llvm-commits] [llvm] r73661 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Message-ID: <200906172343.n5HNha7Z011063@zion.cs.uiuc.edu> Author: asl Date: Wed Jun 17 18:43:36 2009 New Revision: 73661 URL: http://llvm.org/viewvc/llvm-project?rev=73661&view=rev Log: Fix asm string from MOVi16 Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=73661&r1=73660&r2=73661&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Wed Jun 17 18:43:36 2009 @@ -156,7 +156,7 @@ // Move Instructions. // def tMOVi16 : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), - "mov $dst, $src", + "movw $dst, $src", [(set GPR:$dst, imm0_65535:$src)]>, Requires<[HasThumb2]>; From resistor at mac.com Wed Jun 17 18:49:16 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 23:49:16 -0000 Subject: [llvm-commits] [llvm] r73662 - in /llvm/trunk: include/llvm/System/RWMutex.h lib/VMCore/Function.cpp Message-ID: <200906172349.n5HNnJkh011295@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 18:49:06 2009 New Revision: 73662 URL: http://llvm.org/viewvc/llvm-project?rev=73662&view=rev Log: Reapply r73647 in a non-broken form. Modified: llvm/trunk/include/llvm/System/RWMutex.h llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/include/llvm/System/RWMutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/RWMutex.h?rev=73662&r1=73661&r2=73662&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/RWMutex.h (original) +++ llvm/trunk/include/llvm/System/RWMutex.h Wed Jun 17 18:49:06 2009 @@ -79,7 +79,7 @@ /// @} }; - /// ScopedReader - RAII acquisition of a writer lock + /// ScopedReader - RAII acquisition of a reader lock struct ScopedReader { RWMutex* mutex; Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=73662&r1=73661&r2=73662&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Wed Jun 17 18:49:06 2009 @@ -18,6 +18,7 @@ #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/StringPool.h" +#include "llvm/Support/Threading.h" #include "llvm/System/RWMutex.h" #include "SymbolTableListTraitsImpl.h" #include "llvm/ADT/DenseMap.h" @@ -230,21 +231,20 @@ // allocating an additional word in Function for programs which do not use GC // (i.e., most programs) at the cost of increased overhead for clients which do // use GC. -static ManagedStatic > GCNames; -static ManagedStatic GCNamePool; +static DenseMap *GCNames; +static StringPool *GCNamePool; static ManagedStatic GCLock; bool Function::hasGC() const { if (llvm_is_multithreaded()) { sys::ScopedReader Reader(&*GCLock); - return GCNames->count(this); - } else - return GCNames->count(this); + return GCNames && GCNames->count(this); + } else + return GCNames && GCNames->count(this); } const char *Function::getGC() const { assert(hasGC() && "Function has no collector"); - if (llvm_is_multithreaded()) { sys::ScopedReader Reader(&*GCLock); return *(*GCNames)[this]; @@ -253,19 +253,29 @@ } void Function::setGC(const char *Str) { - if (llvm_is_multithreaded()) { - sys::ScopedWriter Writer(&*GCLock); - (*GCNames)[this] = GCNamePool->intern(Str); - } else - (*GCNames)[this] = GCNamePool->intern(Str); + if (llvm_is_multithreaded()) GCLock->writer_acquire(); + if (!GCNamePool) + GCNamePool = new StringPool(); + if (!GCNames) + GCNames = new DenseMap(); + (*GCNames)[this] = GCNamePool->intern(Str); + if (llvm_is_multithreaded()) GCLock->writer_release(); } void Function::clearGC() { - if (llvm_is_multithreaded()) { - sys::ScopedWriter Writer(&*GCLock); - GCNames->erase(this); - } else + if (llvm_is_multithreaded()) GCLock->writer_acquire(); + if (GCNames) { GCNames->erase(this); + if (GCNames->empty()) { + delete GCNames; + GCNames = 0; + if (GCNamePool->empty()) { + delete GCNamePool; + GCNamePool = 0; + } + } + } + if (llvm_is_multithreaded()) GCLock->writer_release(); } /// copyAttributesFrom - copy all additional attributes (those not needed to From fvbommel at wxs.nl Wed Jun 17 18:51:33 2009 From: fvbommel at wxs.nl (Frits van Bommel) Date: Thu, 18 Jun 2009 01:51:33 +0200 Subject: [llvm-commits] [llvm] r73646 - /llvm/trunk/include/llvm/Support/IRBuilder.h In-Reply-To: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> References: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> Message-ID: <4A398185.7070800@wxs.nl> Anton Korobeynikov wrote: > Author: asl > Date: Wed Jun 17 17:20:46 2009 > New Revision: 73646 > > URL: http://llvm.org/viewvc/llvm-project?rev=73646&view=rev > Log: > Honour calling convention and attributes of Callee by default. Shouldn't invokes do this too? From gohman at apple.com Wed Jun 17 18:54:50 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 17 Jun 2009 23:54:50 -0000 Subject: [llvm-commits] [llvm] r73663 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200906172354.n5HNspKd011543@zion.cs.uiuc.edu> Author: djg Date: Wed Jun 17 18:54:37 2009 New Revision: 73663 URL: http://llvm.org/viewvc/llvm-project?rev=73663&view=rev Log: Delete unnecessary braces. 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=73663&r1=73662&r2=73663&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Jun 17 18:54:37 2009 @@ -2408,12 +2408,11 @@ APInt EffectiveMask = APInt::getLowBitsSet(BitWidth, BitWidth - LZ); - if (LZ != 0 && !((~A & ~KnownZero) & EffectiveMask)) { + if (LZ != 0 && !((~A & ~KnownZero) & EffectiveMask)) return getZeroExtendExpr(getTruncateExpr(getSCEV(U->getOperand(0)), IntegerType::get(BitWidth - LZ)), U->getType()); - } } break; From gohman at apple.com Wed Jun 17 19:00:30 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Jun 2009 00:00:30 -0000 Subject: [llvm-commits] [llvm] r73664 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/xor-and.ll Message-ID: <200906180000.n5I00WSi011714@zion.cs.uiuc.edu> Author: djg Date: Wed Jun 17 19:00:20 2009 New Revision: 73664 URL: http://llvm.org/viewvc/llvm-project?rev=73664&view=rev Log: Teach ScalarEvolution how to recognize another xor(and(x, C), C) case. If C is a single bit and the and gets analyzed as a truncate and zero-extend, the xor can be represnted as an add. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=73664&r1=73663&r2=73664&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Jun 17 19:00:20 2009 @@ -2453,10 +2453,25 @@ LCI->getValue() == CI->getValue()) if (const SCEVZeroExtendExpr *Z = dyn_cast(getSCEV(U->getOperand(0)))) { - SCEVHandle ZO = Z->getOperand(); - if (APIntOps::isMask(getTypeSizeInBits(ZO->getType()), - CI->getValue())) - return getZeroExtendExpr(getNotSCEV(ZO), U->getType()); + const Type *UTy = U->getType(); + SCEVHandle Z0 = Z->getOperand(); + const Type *Z0Ty = Z0->getType(); + unsigned Z0TySize = getTypeSizeInBits(Z0Ty); + + // If C is a low-bits mask, the zero extend is zerving to + // mask off the high bits. Complement the operand and + // re-apply the zext. + if (APIntOps::isMask(Z0TySize, CI->getValue())) + return getZeroExtendExpr(getNotSCEV(Z0), UTy); + + // If C is a single bit, it may be in the sign-bit position + // before the zero-extend. In this case, represent the xor + // using an add, which is equivalent, and re-apply the zext. + APInt Trunc = APInt(CI->getValue()).trunc(Z0TySize); + if (APInt(Trunc).zext(getTypeSizeInBits(UTy)) == CI->getValue() && + Trunc.isSignBit()) + return getZeroExtendExpr(getAddExpr(Z0, getConstant(Trunc)), + UTy); } } break; Modified: llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll?rev=73664&r1=73663&r2=73664&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/xor-and.ll Wed Jun 17 19:00:20 2009 @@ -1,6 +1,7 @@ -; RUN: llvm-as < %s | opt -scalar-evolution -disable-output -analyze | grep {\\--> %z} +; RUN: llvm-as < %s | opt -scalar-evolution -disable-output -analyze \ +; RUN: | grep {\\--> (zext i4 (-8 + (trunc i64 (8 \\* %x) to i4)) to i64)} -; ScalarEvolution shouldn't try to analyze %s into something like +; ScalarEvolution shouldn't try to analyze %z into something like ; --> (zext i4 (-1 + (-1 * (trunc i64 (8 * %x) to i4))) to i64) define i64 @foo(i64 %x) { From bob.wilson at apple.com Wed Jun 17 19:36:20 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 18 Jun 2009 00:36:20 -0000 Subject: [llvm-commits] [llvm] r73665 - /llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <200906180036.n5I0aKg8012715@zion.cs.uiuc.edu> Author: bwilson Date: Wed Jun 17 19:36:17 2009 New Revision: 73665 URL: http://llvm.org/viewvc/llvm-project?rev=73665&view=rev Log: ARM unified syntax is not specific to ELF; use it for Darwin, too. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=73665&r1=73664&r2=73665&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Jun 17 19:36:17 2009 @@ -841,7 +841,7 @@ Mang->setUseQuotes(true); // Thumb-2 instructions are supported only in unified assembler syntax mode. - if (Subtarget->isTargetELF() && Subtarget->hasThumb2()) + if (Subtarget->hasThumb2()) O << "\t.syntax unified\n"; // Emit ARM Build Attributes From gohman at apple.com Wed Jun 17 19:37:46 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Jun 2009 00:37:46 -0000 Subject: [llvm-commits] [llvm] r73666 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200906180037.n5I0bkFn012769@zion.cs.uiuc.edu> Author: djg Date: Wed Jun 17 19:37:45 2009 New Revision: 73666 URL: http://llvm.org/viewvc/llvm-project?rev=73666&view=rev Log: Fix trailing whitespace from ScalarEvolution::print. 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=73666&r1=73665&r2=73666&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Jun 17 19:37:45 2009 @@ -4025,10 +4025,9 @@ OS << " --> "; SCEVHandle SV = SE.getSCEV(&*I); SV->print(OS); - OS << "\t\t"; if (const Loop *L = LI->getLoopFor((*I).getParent())) { - OS << "Exits: "; + OS << "\t\t" "Exits: "; SCEVHandle ExitValue = SE.getSCEVAtScope(&*I, L->getParentLoop()); if (!ExitValue->isLoopInvariant(L)) { OS << "<>"; From clattner at apple.com Wed Jun 17 19:39:12 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Jun 2009 17:39:12 -0700 Subject: [llvm-commits] [llvm] r73646 - /llvm/trunk/include/llvm/Support/IRBuilder.h In-Reply-To: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> References: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> Message-ID: <2AC709DE-1579-427A-8D43-B0B0546791FE@apple.com> On Jun 17, 2009, at 3:20 PM, Anton Korobeynikov wrote: > Author: asl > Date: Wed Jun 17 17:20:46 2009 > New Revision: 73646 > > URL: http://llvm.org/viewvc/llvm-project?rev=73646&view=rev > Log: > Honour calling convention and attributes of Callee by default. Anton, why isn't the caller and callee already getting the right calling conv? This seems like the wrong fix, -Chris > > > Modified: > llvm/trunk/include/llvm/Support/IRBuilder.h > > Modified: llvm/trunk/include/llvm/Support/IRBuilder.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=73646&r1=73645&r2=73646&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) > +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Jun 17 17:20:46 > 2009 > @@ -17,6 +17,7 @@ > > #include "llvm/Constants.h" > #include "llvm/Instructions.h" > +#include "llvm/GlobalAlias.h" > #include "llvm/GlobalVariable.h" > #include "llvm/Function.h" > #include "llvm/Support/ConstantFolder.h" > @@ -586,32 +587,49 @@ > return Insert(PHINode::Create(Ty), Name); > } > > + CallInst *TransferAttributes(CallInst *CI, const Value* Callee) > const { > + if (const GlobalAlias *GA = dyn_cast(Callee)) > + Callee = GA->getAliasedGlobal(); > + > + if (const Function *F = dyn_cast(Callee)) { > + CI->setCallingConv(F->getCallingConv()); > + CI->setAttributes(F->getAttributes()); > + } > + > + return CI; > + } > + > CallInst *CreateCall(Value *Callee, const char *Name = "") { > - return Insert(CallInst::Create(Callee), Name); > + return Insert(TransferAttributes(CallInst::Create(Callee), > Callee), Name); > } > CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = > "") { > - return Insert(CallInst::Create(Callee, Arg), Name); > + return Insert(TransferAttributes(CallInst::Create(Callee, Arg), > + Callee), Name); > } > CallInst *CreateCall2(Value *Callee, Value *Arg1, Value *Arg2, > const char *Name = "") { > Value *Args[] = { Arg1, Arg2 }; > - return Insert(CallInst::Create(Callee, Args, Args+2), Name); > + return Insert(TransferAttributes(CallInst::Create(Callee, Args, > Args+2), > + Callee), Name); > } > CallInst *CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, > Value *Arg3, > const char *Name = "") { > Value *Args[] = { Arg1, Arg2, Arg3 }; > - return Insert(CallInst::Create(Callee, Args, Args+3), Name); > + return Insert(TransferAttributes(CallInst::Create(Callee, Args, > Args+3), > + Callee), Name); > } > CallInst *CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, > Value *Arg3, > Value *Arg4, const char *Name = "") { > Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; > - return Insert(CallInst::Create(Callee, Args, Args+4), Name); > + return Insert(TransferAttributes(CallInst::Create(Callee, Args, > Args+4), > + Callee), Name); > } > > template > CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, > InputIterator ArgEnd, const char *Name = "") { > - return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd), Name); > + return Insert(TransferAttributes(CallInst::Create(Callee, > ArgBegin, ArgEnd), > + Callee), Name); > } > > Value *CreateSelect(Value *C, Value *True, Value *False, > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Wed Jun 17 19:40:35 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Jun 2009 17:40:35 -0700 Subject: [llvm-commits] [llvm] r73639 - /llvm/trunk/lib/VMCore/PassManager.cpp In-Reply-To: <200906172128.n5HLStZ0005981@zion.cs.uiuc.edu> References: <200906172128.n5HLStZ0005981@zion.cs.uiuc.edu> Message-ID: <1F24E7A1-1978-4E69-8F9D-FB0372145DD1@apple.com> On Jun 17, 2009, at 2:28 PM, Owen Anderson wrote: > Author: resistor > Date: Wed Jun 17 16:28:54 2009 > New Revision: 73639 > > URL: http://llvm.org/viewvc/llvm-project?rev=73639&view=rev > Log: > Guard mutation of the timing info global. Owen, why does all this code need to explicitly check to see if multithreading is on? It seems like you should change sys::Mutex to take a template argument that indicates whether it does this or not by default. Forcing all the clients to do this is bad. -Chris > > > Modified: > llvm/trunk/lib/VMCore/PassManager.cpp > > Modified: llvm/trunk/lib/VMCore/PassManager.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=73639&r1=73638&r2=73639&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/VMCore/PassManager.cpp (original) > +++ llvm/trunk/lib/VMCore/PassManager.cpp Wed Jun 17 16:28:54 2009 > @@ -20,6 +20,8 @@ > #include "llvm/Support/Streams.h" > #include "llvm/Support/ManagedStatic.h" > #include "llvm/Support/raw_ostream.h" > +#include "llvm/Support/Threading.h" > +#include "llvm/System/Mutex.h" > #include "llvm/Analysis/Dominators.h" > #include "llvm-c/Core.h" > #include > @@ -355,6 +357,9 @@ > /// amount of time each pass takes to execute. This only happens when > /// -time-passes is enabled on the command line. > /// > + > +static ManagedStatic TimingInfoMutex; > + > class VISIBILITY_HIDDEN TimingInfo { > std::map TimingData; > TimerGroup TG; > @@ -379,18 +384,22 @@ > if (dynamic_cast(P)) > return; > > + if (llvm_is_multithreaded()) TimingInfoMutex->acquire(); > std::map::iterator I = TimingData.find(P); > if (I == TimingData.end()) > I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), > TG))).first; > I->second.startTimer(); > + if (llvm_is_multithreaded()) TimingInfoMutex->release(); > } > void passEnded(Pass *P) { > if (dynamic_cast(P)) > return; > > + if (llvm_is_multithreaded()) TimingInfoMutex->acquire(); > std::map::iterator I = TimingData.find(P); > assert(I != TimingData.end() && "passStarted/passEnded not > nested right!"); > I->second.stopTimer(); > + if (llvm_is_multithreaded()) TimingInfoMutex->release(); > } > }; > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dalej at apple.com Wed Jun 17 20:07:23 2009 From: dalej at apple.com (Dale Johannesen) Date: Thu, 18 Jun 2009 01:07:23 -0000 Subject: [llvm-commits] [llvm] r73668 - /llvm/trunk/lib/Target/CBackend/CBackend.cpp Message-ID: <200906180107.n5I17NZr013728@zion.cs.uiuc.edu> Author: johannes Date: Wed Jun 17 20:07:23 2009 New Revision: 73668 URL: http://llvm.org/viewvc/llvm-project?rev=73668&view=rev Log: It looks like nobody is working on PR 4158, so I'm adding a check to catch this case at compile time instead of quietly generating incorrect code. That will at least let us identify CBE failures that are not due to this problem. Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=73668&r1=73667&r2=73668&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Wed Jun 17 20:07:23 2009 @@ -1454,6 +1454,17 @@ /// writeInstComputationInline - Emit the computation for the specified /// instruction inline, with no destination provided. void CWriter::writeInstComputationInline(Instruction &I) { + // We can't currently support integer types other than 1, 8, 16, 32, 64. + // Validate this. + const Type *Ty = I.getType(); + if (Ty->isInteger() && (Ty!=Type::Int1Ty && Ty!=Type::Int8Ty && + Ty!=Type::Int16Ty && Ty!=Type::Int32Ty && Ty!=Type::Int64Ty)) { + cerr << "The C backend does not currently support integer " + << "types of widths other than 1, 8, 16, 32, 64.\n"; + cerr << "This is being tracked as PR 4158.\n"; + abort(); + } + // If this is a non-trivial bool computation, make sure to truncate down to // a 1 bit value. This is important because we want "add i1 x, y" to return // "0" when x and y are true, not "2" for example. From evan.cheng at apple.com Wed Jun 17 20:22:05 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 17 Jun 2009 18:22:05 -0700 Subject: [llvm-commits] [llvm] r73622 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/ARM/thumb2-add.ll test/CodeGen/ARM/thumb2-mov.ll test/CodeGen/ARM/thumb2-mov2.ll test/CodeGen/ARM/thumb2-shifter.ll In-Reply-To: <200906171814.n5HIE08Q030499@zion.cs.uiuc.edu> References: <200906171814.n5HIE08Q030499@zion.cs.uiuc.edu> Message-ID: It would be nice if you can document the instructions with the corresponding ARM instruction manual section (e.g. A8.6.2) and encoding type (T1, T2, etc.). Evan On Jun 17, 2009, at 11:13 AM, Anton Korobeynikov wrote: > Author: asl > Date: Wed Jun 17 13:13:58 2009 > New Revision: 73622 > > URL: http://llvm.org/viewvc/llvm-project?rev=73622&view=rev > Log: > Initial support for some Thumb2 instructions. > Patch by Viktor Kutuzov and Anton Korzh from Access Softek, Inc. > > Added: > llvm/trunk/test/CodeGen/ARM/thumb2-add.ll > llvm/trunk/test/CodeGen/ARM/thumb2-mov.ll > llvm/trunk/test/CodeGen/ARM/thumb2-mov2.ll > llvm/trunk/test/CodeGen/ARM/thumb2-shifter.ll > Modified: > llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp > llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td > llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp > > Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=73622&r1=73621&r2=73622&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Jun 17 > 13:13:58 2009 > @@ -52,8 +52,13 @@ > > virtual const char *getPassName() const { > return "ARM Instruction Selection"; > - } > - > + } > + > + /// getI32Imm - Return a target constant with the specified value, > of type i32. > + inline SDValue getI32Imm(unsigned Imm) { > + return CurDAG->getTargetConstant(Imm, MVT::i32); > + } > + > SDNode *Select(SDValue Op); > virtual void InstructionSelect(); > bool SelectAddrMode2(SDValue Op, SDValue N, SDValue &Base, > @@ -84,6 +89,9 @@ > bool SelectThumbAddrModeSP(SDValue Op, SDValue N, SDValue &Base, > SDValue &OffImm); > > + bool SelectShifterOperand(SDValue Op, SDValue N, > + SDValue &BaseReg, SDValue &Opc); > + > bool SelectShifterOperandReg(SDValue Op, SDValue N, SDValue &A, > SDValue &B, SDValue &C); > > @@ -509,8 +517,30 @@ > return false; > } > > +bool ARMDAGToDAGISel::SelectShifterOperand(SDValue Op, > + SDValue N, > + SDValue &BaseReg, > + SDValue &Opc) { > + ARM_AM::ShiftOpc ShOpcVal = ARM_AM::getShiftOpcForNode(N); > + > + // Don't match base register only case. That is matched to a > separate > + // lower complexity pattern with explicit register operand. > + if (ShOpcVal == ARM_AM::no_shift) return false; > + > + BaseReg = N.getOperand(0); > + unsigned ShImmVal = 0; > + if (ConstantSDNode *RHS = dyn_cast(N.getOperand > (1))) > + ShImmVal = RHS->getZExtValue() & 31; > + else > + return false; > + > + Opc = getI32Imm(ARM_AM::getSORegOpc(ShOpcVal, ShImmVal)); > + > + return true; > +} > + > bool ARMDAGToDAGISel::SelectShifterOperandReg(SDValue Op, > - SDValue N, > + SDValue N, > SDValue &BaseReg, > SDValue &ShReg, > SDValue &Opc) { > @@ -549,6 +579,10 @@ > switch (N->getOpcode()) { > default: break; > case ISD::Constant: { > + // ARMv6T2 and later should materialize imms via MOV / MOVT pair. > + if (Subtarget->hasV6T2Ops() || Subtarget->hasThumb2()) > + break; > + > unsigned Val = cast(N)->getZExtValue(); > bool UseCP = true; > if (Subtarget->isThumb()) > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=73622&r1=73621&r2=73622&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Jun 17 13:13:58 2009 > @@ -1385,6 +1385,12 @@ > include "ARMInstrThumb.td" > > // > = > = > = > ----------------------------------------------------------------------= > ==// > +// Thumb2 Support > +// > + > +include "ARMInstrThumb2.td" > + > +// > = > = > = > ----------------------------------------------------------------------= > ==// > // Floating Point Support > // > > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=73622&r1=73621&r2=73622&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Wed Jun 17 13:13:58 > 2009 > @@ -10,3 +10,199 @@ > // This file describes the Thumb2 instruction set. > // > // > = > = > = > ----------------------------------------------------------------------= > ==// > + > +// Shifted operands. No register controlled shifts for Thumb2. > +// Note: We do not support rrx shifted operands yet. > +def t2_so_reg : Operand, // reg imm > + ComplexPattern + [shl,srl,sra,rotr]> { > + let PrintMethod = "printSOOperand"; > + let MIOperandInfo = (ops GPR, i32imm); > +} > + > +def LO16 : SDNodeXForm + // Transformation function: shift the immediate value down into > the low bits. > + return getI32Imm((unsigned short)N->getZExtValue()); > +}]>; > + > +def HI16 : SDNodeXForm + // Transformation function: shift the immediate value down into > the low bits. > + return getI32Imm((unsigned)N->getZExtValue() >> 16); > +}]>; > + > +def imm16high : PatLeaf<(i32 imm), [{ > + // Returns true if all bits out of the [31..16] range are 0. > + return ((N->getZExtValue() & 0xFFFF0000ULL) == N->getZExtValue()); > +}], HI16>; > + > +def imm16high0xffff : PatLeaf<(i32 imm), [{ > + // Returns true if lo 16 bits are set and this is a 32-bit value. > + return ((N->getZExtValue() & 0x0000FFFFULL) == 0xFFFFULL); > +}], HI16>; > + > +def imm0_4095 : PatLeaf<(i32 imm), [{ > + return (uint32_t)N->getZExtValue() < 4096; > +}]>; > + > +def imm0_4095_neg : PatLeaf<(i32 imm), [{ > + return (uint32_t)-N->getZExtValue() < 4096; > +}], imm_neg_XFORM>; > + > +def imm0_65535 : PatLeaf<(i32 imm), [{ > + return N->getZExtValue() < 65536; > +}]>; > + > +// A6.3.2 Modified immediate constants in Thumb instructions > (#) > +// FIXME: Move it the the addrmode matcher code. > +def t2_so_imm : PatLeaf<(i32 imm), [{ > + uint64_t v = N->getZExtValue(); > + if (v == 0 || v > 0xffffffffUL) return false; > + // variant1 - 0b0000x - 8-bit which could be zero (not supported > for now) > + > + // variant2 - 0b00nnx - 8-bit repeated inside the 32-bit room > + unsigned hi16 = (unsigned)(v >> 16); > + unsigned lo16 = (unsigned)(v & 0xffffUL); > + bool valid = (hi16 == lo16) && ( > + (v & 0x00ff00ffUL) == 0 || // type 0001x > + (v & 0xff00ff00UL) == 0 || // type 0010x > + ((lo16 >> 8) == (lo16 & 0xff))); // type 0011x > + if (valid) return true; > + > + // variant3 - 0b01000..0b11111 - 8-bit shifted inside the 32-bit > room > + unsigned shift = CountLeadingZeros_32(v); > + uint64_t mask = (0xff000000ULL >> shift); > + // If valid, it is type 01000 + shift > + return ((shift < 24) && (v & mask) > 0) && ((v & (~mask)) == 0); > +}]>; > + > + > +// > = > = > = > ----------------------------------------------------------------------= > ==// > +// Thumb-2 to cover the functionality of the ARM instruction set. > +// > + > +/// T2I_bin_irs - Defines a set of (op reg, {so_imm|reg|so_reg}) > patterns for a > +// binary operation that produces a value. > +multiclass T2I_bin_irs { > + // shifted imm > + def ri : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs), > + !strconcat(opc, " $dst, $lhs, $rhs"), > + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm: > $rhs))]>, > + Requires<[HasThumb2]>; > + // register > + def rr : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs), > + !strconcat(opc, " $dst, $lhs, $rhs"), > + [(set GPR:$dst, (opnode GPR:$lhs, GPR:$rhs))] > >, > + Requires<[HasThumb2]>; > + // shifted register > + def rs : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg: > $rhs), > + !strconcat(opc, " $dst, $lhs, $rhs"), > + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg: > $rhs))]>, > + Requires<[HasThumb2]>; > +} > + > +/// T2I_bin_s_irs - Similar to T2I_bin_irs except it sets the 's' > bit so the > +/// instruction modifies the CPSR register. > +let Defs = [CPSR] in { > +multiclass T2I_bin_s_irs { > + // shifted imm > + def ri : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs), > + !strconcat(opc, "s $dst, $lhs, $rhs"), > + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm: > $rhs))]>, > + Requires<[HasThumb2]>; > + > + // register > + def rr : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs), > + !strconcat(opc, "s $dst, $lhs, $rhs"), > + [(set GPR:$dst, (opnode GPR:$lhs, GPR:$rhs))] > >, > + Requires<[HasThumb2]>; > + > + // shifted register > + def rs : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg: > $rhs), > + !strconcat(opc, "s $dst, $lhs, $rhs"), > + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg: > $rhs))]>, > + Requires<[HasThumb2]>; > +} > +} > + > +/// T2I_bin_c_irs - Similar to T2I_bin_irs except it uses the 's' > bit. Also the > +/// instruction can optionally set the CPSR register. > +let Uses = [CPSR] in { > +multiclass T2I_bin_c_irs { > + // shifted imm > + def ri : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs, > cc_out:$s), > + !strconcat(opc, "${s} $dst, $lhs, $rhs"), > + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_imm: > $rhs))]>, > + Requires<[HasThumb2]>; > + > + // register > + def rr : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs, > cc_out:$s), > + !strconcat(opc, "${s} $dst, $lhs, $rhs"), > + [(set GPR:$dst, (opnode GPR:$lhs, GPR:$rhs))] > >, > + Requires<[HasThumb2]>; > + > + // shifted register > + def rs : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, t2_so_reg: > $rhs, cc_out:$s), > + !strconcat(opc, "${s} $dst, $lhs, $rhs"), > + [(set GPR:$dst, (opnode GPR:$lhs, t2_so_reg: > $rhs))]>, > + Requires<[HasThumb2]>; > +} > +} > + > +// > = > = > = > ----------------------------------------------------------------------= > ==// > +// Arithmetic Instructions. > +// > + > +// > = > = > = > ----------------------------------------------------------------------= > ==// > +// Move Instructions. > +// > +def tMOVi16 : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), > + "mov $dst, $src", > + [(set GPR:$dst, imm0_65535:$src)]>, > + Requires<[HasThumb2]>; > + > +let isTwoAddress = 1 in > +def tMOVTi16 : PseudoInst<(outs GPR:$dst), (ins GPR:$src, i32imm: > $imm), > + "movt $dst, $imm", > + [(set GPR:$dst, (or (and GPR:$src, 0xffff), > + imm16high:$imm))]>, > + Requires<[HasThumb2]>; > + > +def : Pat<(and (or GPR:$src, imm16high:$imm1), imm16high0xffff: > $imm2), > + (tMOVTi16 GPR:$src, (HI16 imm16high:$imm1))>, > + Requires<[HasThumb2]>; > + > +def : Pat<(i32 imm:$imm), > + (tMOVTi16 (tMOVi16 (LO16 imm:$imm)),(HI16 imm:$imm))>, > + Requires<[HasThumb2]>; > + > +// > = > = > = > ----------------------------------------------------------------------= > ==// > +// Arithmetic Instructions. > +// > +defm t2ADD : T2I_bin_irs <"add", BinOpFrag<(add node:$LHS, node: > $RHS)>>; > +defm t2SUB : T2I_bin_irs <"sub", BinOpFrag<(sub node:$LHS, node: > $RHS)>>; > + > +def tADDri12 : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, i32imm: > $rhs), > + "add $dst, $lhs, $rhs", > + [(set GPR:$dst, (add GPR:$lhs, > imm0_4095:$rhs))]>, > + Requires<[HasThumb2]>; > +def tSUBri12 : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, i32imm: > $rhs), > + "sub $dst, $lhs, $rhs", > + [(set GPR:$dst, (add GPR:$lhs, > imm0_4095_neg:$rhs))]>, > + Requires<[HasThumb2]>; > + > +defm t2ADDS : T2I_bin_s_irs<"add", BinOpFrag<(addc node:$LHS, node: > $RHS)>>; > +defm t2SUBS : T2I_bin_s_irs<"sub", BinOpFrag<(subc node:$LHS, node: > $RHS)>>; > + > +defm t2ADC : T2I_bin_c_irs<"adc", BinOpFrag<(adde node:$LHS, node: > $RHS)>>; > +defm t2SBC : T2I_bin_c_irs<"sbc", BinOpFrag<(sube node:$LHS, node: > $RHS)>>; > + > + > +def tMLS : PseudoInst<(outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), > + "mls $dst, $a, $b, $c", > + [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR: > $b)))]>, > + Requires<[HasThumb2]>; > + > +def tORNrs : PseudoInst<(outs GPR:$dst), (ins GPR:$src1, t2_so_reg: > $src2), > + "orn $dst, $src1, $src2", > + [(set GPR:$dst, (or GPR:$src1, (not > t2_so_reg: $src2)))]>, > + Requires<[HasThumb2]>; > > Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=73622&r1=73621&r2=73622&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) > +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Jun > 17 13:13:58 2009 > @@ -97,6 +97,7 @@ > const char *Modifier = 0); > void printSOImmOperand(const MachineInstr *MI, int opNum); > void printSOImm2PartOperand(const MachineInstr *MI, int opNum); > + void printSOOperand(const MachineInstr *MI, int OpNum); > void printSORegOperand(const MachineInstr *MI, int opNum); > void printAddrMode2Operand(const MachineInstr *MI, int OpNo); > void printAddrMode2OffsetOperand(const MachineInstr *MI, int > OpNo); > @@ -396,6 +397,28 @@ > printSOImm(O, ARM_AM::getSOImmVal(V2), VerboseAsm, TAI); > } > > +// Constant shifts so_reg is a 3-operand unit corresponding to > register forms of > +// the A5.1 "Addressing Mode 1 - Data-processing operands" forms. > This > +// includes: > +// REG 0 - e.g. R5 > +// REG IMM, SH_OPC - e.g. R5, LSL #3 > +void ARMAsmPrinter::printSOOperand(const MachineInstr *MI, int > OpNum) { > + const MachineOperand &MO1 = MI->getOperand(OpNum); > + const MachineOperand &MO2 = MI->getOperand(OpNum+1); > + > + unsigned Reg = MO1.getReg(); > + assert(TargetRegisterInfo::isPhysicalRegister(Reg)); > + O << TM.getRegisterInfo()->getAsmName(Reg); > + > + // Print the shift opc. > + O << ", " > + << ARM_AM::getShiftOpcStr(ARM_AM::getSORegShOp(MO2.getImm())) > + << " "; > + > + assert(MO2.isImm() && "Not a valid t2_so_reg value!"); > + O << "#" << ARM_AM::getSORegOffset(MO2.getImm()); > +} > + > // so_reg is a 4-operand unit corresponding to register forms of the > A5.1 > // "Addressing Mode 1 - Data-processing operands" forms. This > includes: > // REG 0 0 - e.g. R5 > > Added: llvm/trunk/test/CodeGen/ARM/thumb2-add.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb2-add.ll?rev=73622&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/ARM/thumb2-add.ll (added) > +++ llvm/trunk/test/CodeGen/ARM/thumb2-add.ll Wed Jun 17 13:13:58 2009 > @@ -0,0 +1,50 @@ > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | > grep #255 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | > grep #256 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | > grep #257 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | > grep #4094 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | > grep #4095 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | > grep #4096 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep add | > grep lsl | grep #8 > + > +define i32 @t2ADDrc_255(i32 %lhs) { > + %Rd = add i32 %lhs, 255; > + ret i32 %Rd > +} > + > +define i32 @t2ADDrc_256(i32 %lhs) { > + %Rd = add i32 %lhs, 256; > + ret i32 %Rd > +} > + > +define i32 @t2ADDrc_257(i32 %lhs) { > + %Rd = add i32 %lhs, 257; > + ret i32 %Rd > +} > + > +define i32 @t2ADDrc_4094(i32 %lhs) { > + %Rd = add i32 %lhs, 4094; > + ret i32 %Rd > +} > + > +define i32 @t2ADDrc_4095(i32 %lhs) { > + %Rd = add i32 %lhs, 4095; > + ret i32 %Rd > +} > + > +define i32 @t2ADDrc_4096(i32 %lhs) { > + %Rd = add i32 %lhs, 4096; > + ret i32 %Rd > +} > + > +define i32 @t2ADDrr(i32 %lhs, i32 %rhs) { > + %Rd = add i32 %lhs, %rhs; > + ret i32 %Rd > +} > + > +define i32 @t2ADDrs(i32 %lhs, i32 %rhs) { > + %tmp = shl i32 %rhs, 8 > + %Rd = add i32 %lhs, %tmp; > + ret i32 %Rd > +} > + > > Added: llvm/trunk/test/CodeGen/ARM/thumb2-mov.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb2-mov.ll?rev=73622&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/ARM/thumb2-mov.ll (added) > +++ llvm/trunk/test/CodeGen/ARM/thumb2-mov.ll Wed Jun 17 13:13:58 2009 > @@ -0,0 +1,127 @@ > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep > #11206827 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep > #2868947712 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep > #2880154539 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep > #251658240 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep #3948544 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep #258 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep > #4026531840 > + > +; Test # > + > +; var 2.1 - 0x00ab00ab > +define i32 @t2_const_var2_1_ok_1(i32 %lhs) { > + %ret = add i32 %lhs, 11206827 ; 0x00ab00ab > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_1_fail_1(i32 %lhs) { > + %ret = add i32 %lhs, 11206843 ; 0x00ab00bb > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_1_fail_2(i32 %lhs) { > + %ret = add i32 %lhs, 27984043 ; 0x01ab00ab > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_1_fail_3(i32 %lhs) { > + %ret = add i32 %lhs, 27984299 ; 0x01ab01ab > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_1_fail_4(i32 %lhs) { > + %ret = add i32 %lhs, 28027649 ; 0x01abab01 > + ret i32 %ret > +} > + > +; var 2.2 - 0xab00ab00 > +define i32 @t2_const_var2_2_ok_1(i32 %lhs) { > + %ret = add i32 %lhs, 2868947712 ; 0xab00ab00 > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_2_fail_1(i32 %lhs) { > + %ret = add i32 %lhs, 2868951552 ; 0xab00ba00 > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_2_fail_2(i32 %lhs) { > + %ret = add i32 %lhs, 2868947728 ; 0xab00ab10 > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_2_fail_3(i32 %lhs) { > + %ret = add i32 %lhs, 2869996304 ; 0xab10ab10 > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_2_fail_4(i32 %lhs) { > + %ret = add i32 %lhs, 279685904 ; 0x10abab10 > + ret i32 %ret > +} > + > +; var 2.3 - 0xabababab > +define i32 @t2_const_var2_3_ok_1(i32 %lhs) { > + %ret = add i32 %lhs, 2880154539 ; 0xabababab > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_3_fail_1(i32 %lhs) { > + %ret = add i32 %lhs, 2880154554 ; 0xabababba > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_3_fail_2(i32 %lhs) { > + %ret = add i32 %lhs, 2880158379 ; 0xababbaab > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_3_fail_3(i32 %lhs) { > + %ret = add i32 %lhs, 2881137579 ; 0xabbaabab > + ret i32 %ret > +} > + > +define i32 @t2_const_var2_3_fail_4(i32 %lhs) { > + %ret = add i32 %lhs, 3131812779 ; 0xbaababab > + ret i32 %ret > +} > + > +; var 3 - 0x0F000000 > +define i32 @t2_const_var3_1_ok_1(i32 %lhs) { > + %ret = add i32 %lhs, 251658240 ; 0x0F000000 > + ret i32 %ret > +} > + > +define i32 @t2_const_var3_2_ok_1(i32 %lhs) { > + %ret = add i32 %lhs, 3948544 ; 0b00000000001111000100000000000000 > + ret i32 %ret > +} > + > +define i32 @t2_const_var3_2_fail_1(i32 %lhs) { > + %ret = add i32 %lhs, 3940352 ; 0b00000000001111000010000000000000 > + ret i32 %ret > +} > + > +define i32 @t2_const_var3_3_ok_1(i32 %lhs) { > + %ret = add i32 %lhs, 258 ; 0b00000000000000000000000100000010 > + ret i32 %ret > +} > + > +define i32 @t2_const_var3_4_ok_1(i32 %lhs) { > + %ret = add i32 %lhs, 4026531840 ; 0xF0000000 > + ret i32 %ret > +} > + > > Added: llvm/trunk/test/CodeGen/ARM/thumb2-mov2.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb2-mov2.ll?rev=73622&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/ARM/thumb2-mov2.ll (added) > +++ llvm/trunk/test/CodeGen/ARM/thumb2-mov2.ll Wed Jun 17 13:13:58 > 2009 > @@ -0,0 +1,65 @@ > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movt | > grep #1234 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movt | > grep #1234 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movt | > grep #1234 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep movt | > grep #1234 > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov | > grep movt > + > +define i32 @t2MOVTi16_ok_1(i32 %a) { > + %1 = and i32 %a, 65535 > + %2 = shl i32 1234, 16 > + %3 = or i32 %1, %2 > + > + ret i32 %3 > +} > + > +define i32 @t2MOVTi16_test_1(i32 %a) { > + %1 = shl i32 255, 8 > + %2 = shl i32 1234, 8 > + %3 = or i32 %1, 255 ; This give us 0xFFFF in %3 > + %4 = shl i32 %2, 8 ; This gives us (1234 << 16) in %4 > + %5 = and i32 %a, %3 > + %6 = or i32 %4, %5 > + > + ret i32 %6 > +} > + > +define i32 @t2MOVTi16_test_2(i32 %a) { > + %1 = shl i32 255, 8 > + %2 = shl i32 1234, 8 > + %3 = or i32 %1, 255 ; This give us 0xFFFF in %3 > + %4 = shl i32 %2, 6 > + %5 = and i32 %a, %3 > + %6 = shl i32 %4, 2 ; This gives us (1234 << 16) in %6 > + %7 = or i32 %5, %6 > + > + ret i32 %7 > +} > + > +define i32 @t2MOVTi16_test_3(i32 %a) { > + %1 = shl i32 255, 8 > + %2 = shl i32 1234, 8 > + %3 = or i32 %1, 255 ; This give us 0xFFFF in %3 > + %4 = shl i32 %2, 6 > + %5 = and i32 %a, %3 > + %6 = shl i32 %4, 2 ; This gives us (1234 << 16) in %6 > + %7 = lshr i32 %6, 6 > + %8 = shl i32 %7, 6 > + %9 = or i32 %5, %8 > + > + ret i32 %9 > +} > + > +define i32 @t2MOVTi16_test_nomatch_1(i32 %a) { > + %1 = shl i32 255, 8 > + %2 = shl i32 1234, 8 > + %3 = or i32 %1, 255 ; This give us 0xFFFF in %3 > + %4 = shl i32 %2, 6 > + %5 = and i32 %a, %3 > + %6 = shl i32 %4, 2 ; This gives us (1234 << 16) in %6 > + %7 = lshr i32 %6, 3 > + %8 = or i32 %5, %7 > + > + ret i32 %8 > +} > + > + > > Added: llvm/trunk/test/CodeGen/ARM/thumb2-shifter.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/thumb2-shifter.ll?rev=73622&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/ARM/thumb2-shifter.ll (added) > +++ llvm/trunk/test/CodeGen/ARM/thumb2-shifter.ll Wed Jun 17 > 13:13:58 2009 > @@ -0,0 +1,40 @@ > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep lsl > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep lsr > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep asr > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep ror > +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep mov > + > +define i32 @t2ADDrs_lsl(i32 %X, i32 %Y) { > + %A = shl i32 %Y, 16 > + %B = add i32 %X, %A > + ret i32 %B > +} > + > +define i32 @t2ADDrs_lsr(i32 %X, i32 %Y) { > + %A = lshr i32 %Y, 16 > + %B = add i32 %X, %A > + ret i32 %B > +} > + > +define i32 @t2ADDrs_asr(i32 %X, i32 %Y) { > + %A = ashr i32 %Y, 16 > + %B = add i32 %X, %A > + ret i32 %B > +} > + > +; i32 ror(n) = (x >> n) | (x << (32 - n)) > +define i32 @t2ADDrs_ror(i32 %X, i32 %Y) { > + %A = lshr i32 %Y, 16 > + %B = shl i32 %Y, 16 > + %C = or i32 %B, %A > + %R = add i32 %X, %C > + ret i32 %R > +} > + > +define i32 @t2ADDrs_noRegShift(i32 %X, i32 %Y, i8 %sh) { > + %shift.upgrd.1 = zext i8 %sh to i32 > + %A = shl i32 %Y, %shift.upgrd.1 > + %B = add i32 %X, %A > + ret i32 %B > +} > + > > > _______________________________________________ > 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 Wed Jun 17 21:04:01 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 18 Jun 2009 02:04:01 -0000 Subject: [llvm-commits] [llvm] r73671 - in /llvm/trunk: include/llvm/Target/TargetRegisterInfo.h lib/CodeGen/RegAllocLinearScan.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp lib/Target/ARM/ARMLoadStoreOptimizer.cpp lib/Target/ARM/ARMRegisterInfo.cpp lib/Target/ARM/ARMRegisterInfo.h Message-ID: <200906180204.n5I242sc015544@zion.cs.uiuc.edu> Author: evancheng Date: Wed Jun 17 21:04:01 2009 New Revision: 73671 URL: http://llvm.org/viewvc/llvm-project?rev=73671&view=rev Log: - Update register allocation hint after coalescing. This is done by the target since the hint is target dependent. This is important for ARM register pair hints. - Register allocator should resolve the second part of the hint (register number) before passing it to the target since it knows virtual register to physical register mapping. - More fixes to get ARM load / store double word working. Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=73671&r1=73670&r2=73671&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Wed Jun 17 21:04:01 2009 @@ -523,7 +523,7 @@ /// register class in the form of a pair of TargetRegisterClass iterators. virtual std::pair getAllocationOrder(const TargetRegisterClass *RC, - std::pair Hint, + unsigned HintType, unsigned HintReg, const MachineFunction &MF) const { return std::make_pair(RC->allocation_order_begin(MF), RC->allocation_order_end(MF)); @@ -531,13 +531,24 @@ /// ResolveRegAllocHint - Resolves the specified register allocation hint /// to a physical register. Returns the physical register if it is successful. - unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg, - const MachineFunction &MF) const { + virtual unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg, + const MachineFunction &MF) const { if (Type == 0 && Reg && isPhysicalRegister(Reg)) return Reg; return 0; } + /// UpdateRegAllocHint - A callback to allow target a chance to update + /// register allocation hints when a register is "changed" (e.g. coalesced) + /// to another register. e.g. On ARM, some virtual registers should target + /// register pairs, if one of pair is coalesced to another register, the + /// allocation hint of the other half of the pair should be changed to point + /// to the new register. + virtual void UpdateRegAllocHint(unsigned Reg, unsigned NewReg, + MachineFunction &MF) const { + // Do nothing. + } + /// targetHandlesStackFrameRounding - Returns true if the target is /// responsible for rounding up the stack frame (probably at emitPrologue /// time). Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=73671&r1=73670&r2=73671&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Wed Jun 17 21:04:01 2009 @@ -1356,9 +1356,15 @@ unsigned FreeReg = 0; unsigned FreeRegInactiveCount = 0; + std::pair Hint = mri_->getRegAllocationHint(cur->reg); + // Resolve second part of the hint (if possible) given the current allocation. + unsigned physReg = Hint.second; + if (physReg && + TargetRegisterInfo::isVirtualRegister(physReg) && vrm_->hasPhys(physReg)) + physReg = vrm_->getPhys(physReg); + TargetRegisterClass::iterator I, E; - tie(I, E) = tri_->getAllocationOrder(RC, - mri_->getRegAllocationHint(cur->reg), *mf_); + tie(I, E) = tri_->getAllocationOrder(RC, Hint.first, physReg, *mf_); assert(I != E && "No allocatable register in this register class!"); // Scan for the first available register. Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=73671&r1=73670&r2=73671&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Wed Jun 17 21:04:01 2009 @@ -1766,6 +1766,9 @@ // being merged. li_->removeInterval(SrcReg); + // Update regalloc hint. + tri_->UpdateRegAllocHint(SrcReg, DstReg, *mf_); + // Manually deleted the live interval copy. if (SavedLI) { SavedLI->clear(); Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=73671&r1=73670&r2=73671&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Wed Jun 17 21:04:01 2009 @@ -41,6 +41,12 @@ STATISTIC(NumFLDMGened, "Number of fldm instructions generated"); STATISTIC(NumFSTMGened, "Number of fstm instructions generated"); STATISTIC(NumLdStMoved, "Number of load / store instructions moved"); +STATISTIC(NumLDRDFormed,"Number of ldrd created before allocation"); +STATISTIC(NumSTRDFormed,"Number of strd created before allocation"); +STATISTIC(NumLDRD2LDM, "Number of ldrd instructions turned back into ldm"); +STATISTIC(NumSTRD2STM, "Number of strd instructions turned back into stm"); +STATISTIC(NumLDRD2LDR, "Number of ldrd instructions turned back into ldr's"); +STATISTIC(NumSTRD2STR, "Number of strd instructions turned back into str's"); /// ARMAllocLoadStoreOpt - Post- register allocation pass the combine /// load / store instructions to form ldm / stm instructions. @@ -651,9 +657,9 @@ if ((EvenRegNum & 1) == 0 && (EvenRegNum + 1) == OddRegNum) return false; - bool isDef = Opcode == ARM::LDRD; - bool EvenKill = isDef ? false : MI->getOperand(0).isKill(); - bool OddKill = isDef ? false : MI->getOperand(1).isKill(); + bool isLd = Opcode == ARM::LDRD; + bool EvenKill = isLd ? false : MI->getOperand(0).isKill(); + bool OddKill = isLd ? false : MI->getOperand(1).isKill(); const MachineOperand &BaseOp = MI->getOperand(2); unsigned BaseReg = BaseOp.getReg(); bool BaseKill = BaseOp.isKill(); @@ -668,34 +674,49 @@ // Ascending register numbers and no offset. It's safe to change it to a // ldm or stm. unsigned NewOpc = (Opcode == ARM::LDRD) ? ARM::LDM : ARM::STM; - BuildMI(MBB, MBBI, MBBI->getDebugLoc(), TII->get(NewOpc)) - .addReg(BaseReg, getKillRegState(BaseKill)) - .addImm(ARM_AM::getAM4ModeImm(ARM_AM::ia)) - .addImm(Pred).addReg(PredReg) - .addReg(EvenReg, getDefRegState(isDef)) - .addReg(OddReg, getDefRegState(isDef)); + if (isLd) { + BuildMI(MBB, MBBI, MBBI->getDebugLoc(), TII->get(NewOpc)) + .addReg(BaseReg, getKillRegState(BaseKill)) + .addImm(ARM_AM::getAM4ModeImm(ARM_AM::ia)) + .addImm(Pred).addReg(PredReg) + .addReg(EvenReg, getDefRegState(isLd)) + .addReg(OddReg, getDefRegState(isLd)); + ++NumLDRD2LDM; + } else { + BuildMI(MBB, MBBI, MBBI->getDebugLoc(), TII->get(NewOpc)) + .addReg(BaseReg, getKillRegState(BaseKill)) + .addImm(ARM_AM::getAM4ModeImm(ARM_AM::ia)) + .addImm(Pred).addReg(PredReg) + .addReg(EvenReg, getKillRegState(EvenKill)) + .addReg(OddReg, getKillRegState(OddKill)); + ++NumSTRD2STM; + } } else { // Split into two instructions. unsigned NewOpc = (Opcode == ARM::LDRD) ? ARM::LDR : ARM::STR; DebugLoc dl = MBBI->getDebugLoc(); // If this is a load and base register is killed, it may have been // re-defed by the load, make sure the first load does not clobber it. - if (isDef && + if (isLd && (BaseKill || OffKill) && (TRI->regsOverlap(EvenReg, BaseReg) || (OffReg && TRI->regsOverlap(EvenReg, OffReg)))) { assert(!TRI->regsOverlap(OddReg, BaseReg) && (!OffReg || !TRI->regsOverlap(OddReg, OffReg))); - InsertLDR_STR(MBB, MBBI, OffImm+4, isDef, dl, NewOpc, OddReg, OddKill, + InsertLDR_STR(MBB, MBBI, OffImm+4, isLd, dl, NewOpc, OddReg, OddKill, BaseReg, false, OffReg, false, Pred, PredReg, TII); - InsertLDR_STR(MBB, MBBI, OffImm, isDef, dl, NewOpc, EvenReg, EvenKill, + InsertLDR_STR(MBB, MBBI, OffImm, isLd, dl, NewOpc, EvenReg, EvenKill, BaseReg, BaseKill, OffReg, OffKill, Pred, PredReg, TII); } else { - InsertLDR_STR(MBB, MBBI, OffImm, isDef, dl, NewOpc, EvenReg, EvenKill, + InsertLDR_STR(MBB, MBBI, OffImm, isLd, dl, NewOpc, EvenReg, EvenKill, BaseReg, false, OffReg, false, Pred, PredReg, TII); - InsertLDR_STR(MBB, MBBI, OffImm+4, isDef, dl, NewOpc, OddReg, OddKill, + InsertLDR_STR(MBB, MBBI, OffImm+4, isLd, dl, NewOpc, OddReg, OddKill, BaseReg, BaseKill, OffReg, OffKill, Pred, PredReg, TII); } + if (isLd) + ++NumLDRD2LDR; + else + ++NumSTRD2STR; } MBBI = prior(MBBI); @@ -1069,6 +1090,7 @@ MachineInstr *FirstOp = 0; MachineInstr *LastOp = 0; int LastOffset = 0; + unsigned LastOpcode = 0; unsigned LastBytes = 0; unsigned NumMove = 0; for (int i = Ops.size() - 1; i >= 0; --i) { @@ -1083,6 +1105,10 @@ LastOp = Op; } + unsigned Opcode = Op->getOpcode(); + if (LastOpcode && Opcode != LastOpcode) + break; + int Offset = getMemoryOpOffset(Op); unsigned Bytes = getLSMultipleTransferSize(Op); if (LastBytes) { @@ -1091,6 +1117,7 @@ } LastOffset = Offset; LastBytes = Bytes; + LastOpcode = Opcode; if (++NumMove == 4) break; } @@ -1131,22 +1158,25 @@ Offset, PredReg, Pred)) { Ops.pop_back(); Ops.pop_back(); - MBB->erase(Op0); - MBB->erase(Op1); // Form the pair instruction. - if (isLd) + if (isLd) { BuildMI(*MBB, InsertPos, dl, TII->get(NewOpc)) .addReg(EvenReg, RegState::Define) .addReg(OddReg, RegState::Define) .addReg(BaseReg).addReg(0).addImm(Offset) .addImm(Pred).addReg(PredReg); - else + ++NumLDRDFormed; + } else { BuildMI(*MBB, InsertPos, dl, TII->get(NewOpc)) .addReg(EvenReg) .addReg(OddReg) .addReg(BaseReg).addReg(0).addImm(Offset) .addImm(Pred).addReg(PredReg); + ++NumSTRDFormed; + } + MBB->erase(Op0); + MBB->erase(Op1); // Add register allocation hints to form register pairs. MRI->setRegAllocationHint(EvenReg, ARMRI::RegPairEven, OddReg); Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp?rev=73671&r1=73670&r2=73671&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Wed Jun 17 21:04:01 2009 @@ -308,7 +308,7 @@ /// register class in the form of a pair of TargetRegisterClass iterators. std::pair ARMRegisterInfo::getAllocationOrder(const TargetRegisterClass *RC, - std::pair Hint, + unsigned HintType, unsigned HintReg, const MachineFunction &MF) const { // Alternative register allocation orders when favoring even / odd registers // of register pairs. @@ -384,7 +384,13 @@ }; - if (Hint.first == ARMRI::RegPairEven) { + if (HintType == ARMRI::RegPairEven) { + if (isPhysicalRegister(HintReg) && getRegisterPairEven(HintReg, MF) == 0) + // It's no longer possible to fulfill this hint. Return the default + // allocation order. + return std::make_pair(RC->allocation_order_begin(MF), + RC->allocation_order_end(MF)); + if (!STI.isTargetDarwin() && !hasFP(MF)) { if (!STI.isR9Reserved()) return std::make_pair(GPREven1, @@ -407,7 +413,13 @@ return std::make_pair(GPREven6, GPREven6 + (sizeof(GPREven6)/sizeof(unsigned))); } - } else if (Hint.first == ARMRI::RegPairOdd) { + } else if (HintType == ARMRI::RegPairOdd) { + if (isPhysicalRegister(HintReg) && getRegisterPairOdd(HintReg, MF) == 0) + // It's no longer possible to fulfill this hint. Return the default + // allocation order. + return std::make_pair(RC->allocation_order_begin(MF), + RC->allocation_order_end(MF)); + if (!STI.isTargetDarwin() && !hasFP(MF)) { if (!STI.isR9Reserved()) return std::make_pair(GPROdd1, @@ -453,6 +465,26 @@ return 0; } +void +ARMRegisterInfo::UpdateRegAllocHint(unsigned Reg, unsigned NewReg, + MachineFunction &MF) const { + MachineRegisterInfo *MRI = &MF.getRegInfo(); + std::pair Hint = MRI->getRegAllocationHint(Reg); + if ((Hint.first == (unsigned)ARMRI::RegPairOdd || + Hint.first == (unsigned)ARMRI::RegPairEven) && + Hint.second && TargetRegisterInfo::isVirtualRegister(Hint.second)) { + // If 'Reg' is one of the even / odd register pair and it's now changed + // (e.g. coalesced) into a different register. The other register of the + // pair allocation hint must be updated to reflect the relationship + // change. + unsigned OtherReg = Hint.second; + Hint = MRI->getRegAllocationHint(OtherReg); + if (Hint.second == Reg) + // Make sure the pair has not already divorced. + MRI->setRegAllocationHint(OtherReg, Hint.first, NewReg); + } +} + bool ARMRegisterInfo::requiresRegisterScavenging(const MachineFunction &MF) const { const ARMFunctionInfo *AFI = MF.getInfo(); @@ -1680,68 +1712,68 @@ default: break; // Return 0 if either register of the pair is a special register. // So no R12, etc. - case ARM::R0: case ARM::R1: + case ARM::R1: return ARM::R0; - case ARM::R2: case ARM::R3: + case ARM::R3: // FIXME! return STI.isThumb() ? 0 : ARM::R2; - case ARM::R4: case ARM::R5: + case ARM::R5: return ARM::R4; - case ARM::R6: case ARM::R7: + case ARM::R7: return isReservedReg(MF, ARM::R7) ? 0 : ARM::R6; - case ARM::R8: case ARM::R9: + case ARM::R9: return isReservedReg(MF, ARM::R9) ? 0 :ARM::R8; - case ARM::R10: case ARM::R11: + case ARM::R11: return isReservedReg(MF, ARM::R11) ? 0 : ARM::R10; - case ARM::S0: case ARM::S1: + case ARM::S1: return ARM::S0; - case ARM::S2: case ARM::S3: + case ARM::S3: return ARM::S2; - case ARM::S4: case ARM::S5: + case ARM::S5: return ARM::S4; - case ARM::S6: case ARM::S7: + case ARM::S7: return ARM::S6; - case ARM::S8: case ARM::S9: + case ARM::S9: return ARM::S8; - case ARM::S10: case ARM::S11: + case ARM::S11: return ARM::S10; - case ARM::S12: case ARM::S13: + case ARM::S13: return ARM::S12; - case ARM::S14: case ARM::S15: + case ARM::S15: return ARM::S14; - case ARM::S16: case ARM::S17: + case ARM::S17: return ARM::S16; - case ARM::S18: case ARM::S19: + case ARM::S19: return ARM::S18; - case ARM::S20: case ARM::S21: + case ARM::S21: return ARM::S20; - case ARM::S22: case ARM::S23: + case ARM::S23: return ARM::S22; - case ARM::S24: case ARM::S25: + case ARM::S25: return ARM::S24; - case ARM::S26: case ARM::S27: + case ARM::S27: return ARM::S26; - case ARM::S28: case ARM::S29: + case ARM::S29: return ARM::S28; - case ARM::S30: case ARM::S31: + case ARM::S31: return ARM::S30; - case ARM::D0: case ARM::D1: + case ARM::D1: return ARM::D0; - case ARM::D2: case ARM::D3: + case ARM::D3: return ARM::D2; - case ARM::D4: case ARM::D5: + case ARM::D5: return ARM::D4; - case ARM::D6: case ARM::D7: + case ARM::D7: return ARM::D6; - case ARM::D8: case ARM::D9: + case ARM::D9: return ARM::D8; - case ARM::D10: case ARM::D11: + case ARM::D11: return ARM::D10; - case ARM::D12: case ARM::D13: + case ARM::D13: return ARM::D12; - case ARM::D14: case ARM::D15: + case ARM::D15: return ARM::D14; } @@ -1754,68 +1786,68 @@ default: break; // Return 0 if either register of the pair is a special register. // So no R12, etc. - case ARM::R0: case ARM::R1: + case ARM::R0: return ARM::R1; - case ARM::R2: case ARM::R3: + case ARM::R2: // FIXME! return STI.isThumb() ? 0 : ARM::R3; - case ARM::R4: case ARM::R5: + case ARM::R4: return ARM::R5; - case ARM::R6: case ARM::R7: + case ARM::R6: return isReservedReg(MF, ARM::R7) ? 0 : ARM::R7; - case ARM::R8: case ARM::R9: + case ARM::R8: return isReservedReg(MF, ARM::R9) ? 0 :ARM::R9; - case ARM::R10: case ARM::R11: + case ARM::R10: return isReservedReg(MF, ARM::R11) ? 0 : ARM::R11; - case ARM::S0: case ARM::S1: + case ARM::S0: return ARM::S1; - case ARM::S2: case ARM::S3: + case ARM::S2: return ARM::S3; - case ARM::S4: case ARM::S5: + case ARM::S4: return ARM::S5; - case ARM::S6: case ARM::S7: + case ARM::S6: return ARM::S7; - case ARM::S8: case ARM::S9: + case ARM::S8: return ARM::S9; - case ARM::S10: case ARM::S11: + case ARM::S10: return ARM::S11; - case ARM::S12: case ARM::S13: + case ARM::S12: return ARM::S13; - case ARM::S14: case ARM::S15: + case ARM::S14: return ARM::S15; - case ARM::S16: case ARM::S17: + case ARM::S16: return ARM::S17; - case ARM::S18: case ARM::S19: + case ARM::S18: return ARM::S19; - case ARM::S20: case ARM::S21: + case ARM::S20: return ARM::S21; - case ARM::S22: case ARM::S23: + case ARM::S22: return ARM::S23; - case ARM::S24: case ARM::S25: + case ARM::S24: return ARM::S25; - case ARM::S26: case ARM::S27: + case ARM::S26: return ARM::S27; - case ARM::S28: case ARM::S29: + case ARM::S28: return ARM::S29; - case ARM::S30: case ARM::S31: + case ARM::S30: return ARM::S31; - case ARM::D0: case ARM::D1: + case ARM::D0: return ARM::D1; - case ARM::D2: case ARM::D3: + case ARM::D2: return ARM::D3; - case ARM::D4: case ARM::D5: + case ARM::D4: return ARM::D5; - case ARM::D6: case ARM::D7: + case ARM::D6: return ARM::D7; - case ARM::D8: case ARM::D9: + case ARM::D8: return ARM::D9; - case ARM::D10: case ARM::D11: + case ARM::D10: return ARM::D11; - case ARM::D12: case ARM::D13: + case ARM::D12: return ARM::D13; - case ARM::D14: case ARM::D15: + case ARM::D14: return ARM::D15; } Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h?rev=73671&r1=73670&r2=73671&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.h Wed Jun 17 21:04:01 2009 @@ -70,12 +70,15 @@ std::pair getAllocationOrder(const TargetRegisterClass *RC, - std::pair Hint, + unsigned HintType, unsigned HintReg, const MachineFunction &MF) const; unsigned ResolveRegAllocHint(unsigned Type, unsigned Reg, const MachineFunction &MF) const; + void UpdateRegAllocHint(unsigned Reg, unsigned NewReg, + MachineFunction &MF) const; + bool requiresRegisterScavenging(const MachineFunction &MF) const; bool hasFP(const MachineFunction &MF) const; From sylvere.teissier at invia.fr Wed Jun 17 16:57:25 2009 From: sylvere.teissier at invia.fr (sylvere.teissier at invia.fr) Date: Wed, 17 Jun 2009 23:57:25 +0200 Subject: [llvm-commits] [llvm] r73579 - in /llvm/trunk:Makefile.rulesdocs/MakefileGuide.html tools/llvmc/driver/Makefile Message-ID: <26747709.99891245275845465.JavaMail.servlet@kundenserver> >What change is needed? see attached patch that compile but still doesn't work >I'm not familiar with llvmc, what isn't working? the llvmc binary created is "empty", there is only the body available: running llvmc -help output: OVERVIEW: LLVM Compiler Driver (Work In Progress) USAGE: llvmc [options] OPTIONS: -dry-run - Only pretend to run commands -help - Display available options (--help-hidden for more) -load= - Load the specified plugin -o= - Output file name -v - Enable verbose mode -version - Display the version of this program -x= - Specify the language of the following input files so the base and clang plugins that permit to use llvm-gcc and clang front-end are not linked to llvmc. They were linked with llvmc before your patch. The same behavior happen with the examples. I'm not expert with llvmc internals neither the buid system so I can't help you more :( -------------- next part -------------- A non-text attachment was scrubbed... Name: patch Type: application/octet-stream Size: 1251 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/cad50524/attachment.obj From the.dead.shall.rise at gmail.com Wed Jun 17 20:41:40 2009 From: the.dead.shall.rise at gmail.com (Mikhail Glushenkov) Date: Thu, 18 Jun 2009 01:41:40 +0000 (UTC) Subject: [llvm-commits] =?utf-8?q?=5Bllvm=5D_r73579_-_in_/llvm/trunk=3A=09?= =?utf-8?q?Makefile=2Erules=09docs/MakefileGuide=2Ehtml_tools/llvmc?= =?utf-8?q?/driver/Makefile?= References: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> <1245246876.6797.19.camel@vostro-1510.invia> Message-ID: Hi Sylvere, Sylvere Teissier writes: > Furthermore, llvmc seems to be broken in my config. > It doesn't contains clang and base plugins, or is it intentional ? Yep, this change broke llvmc for me too. I'll see what needs to be done. From howard0su at gmail.com Wed Jun 17 21:18:37 2009 From: howard0su at gmail.com (Howard Su) Date: Thu, 18 Jun 2009 10:18:37 +0800 Subject: [llvm-commits] [llvm] r73636 - /llvm/trunk/lib/VMCore/Pass.cpp In-Reply-To: <200906172116.n5HLGSsF005548@zion.cs.uiuc.edu> References: <200906172116.n5HLGSsF005548@zion.cs.uiuc.edu> Message-ID: I don't think this is worth for this sort of optimization. Double check lock only optimize out a lock. However since this function is not a freqently called function, this optimization is not that useful. I suggest you just lock and check the flag. On Thu, Jun 18, 2009 at 5:16 AM, Owen Anderson wrote: > Author: resistor > Date: Wed Jun 17 16:16:20 2009 > New Revision: 73636 > > URL: http://llvm.org/viewvc/llvm-project?rev=73636&view=rev > Log: > We need to use double-checked locking for lazy initialization in this case > when running multithreaded. > > Modified: > llvm/trunk/lib/VMCore/Pass.cpp > > Modified: llvm/trunk/lib/VMCore/Pass.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=73636&r1=73635&r2=73636&view=diff > > > ============================================================================== > --- llvm/trunk/lib/VMCore/Pass.cpp (original) > +++ llvm/trunk/lib/VMCore/Pass.cpp Wed Jun 17 16:16:20 2009 > @@ -19,6 +19,8 @@ > #include "llvm/ModuleProvider.h" > #include "llvm/ADT/STLExtras.h" > #include "llvm/Support/ManagedStatic.h" > +#include "llvm/Support/Threading.h" > +#include "llvm/System/Atomic.h" > #include > #include > #include > @@ -192,8 +194,20 @@ > // ressurection after llvm_shutdown is run. > static PassRegistrar *getPassRegistrar() { > static PassRegistrar *PassRegistrarObj = 0; > + > + // Use double-checked locking to safely initialize the registrar when > + // we're running in multithreaded mode. > if (!PassRegistrarObj) > - PassRegistrarObj = new PassRegistrar(); > + if (llvm_is_multithreaded()) { > + llvm_acquire_global_lock(); > + if (!PassRegistrarObj) { > + PassRegistrar* tmp = new PassRegistrar(); > + sys::MemoryFence(); > + PassRegistrarObj = tmp; > + } > + llvm_release_global_lock(); > + } else > + PassRegistrarObj = new PassRegistrar(); > return PassRegistrarObj; > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- -Howard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090618/521fd38d/attachment.html From nicholas at mxc.ca Wed Jun 17 22:01:44 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 18 Jun 2009 03:01:44 -0000 Subject: [llvm-commits] [llvm] r73673 - /llvm/trunk/lib/VMCore/Pass.cpp Message-ID: <200906180301.n5I31iUf017093@zion.cs.uiuc.edu> Author: nicholas Date: Wed Jun 17 22:01:42 2009 New Revision: 73673 URL: http://llvm.org/viewvc/llvm-project?rev=73673&view=rev Log: Add braces to clarify if/else structure and remove warning. Modified: llvm/trunk/lib/VMCore/Pass.cpp Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=73673&r1=73672&r2=73673&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Wed Jun 17 22:01:42 2009 @@ -197,7 +197,7 @@ // Use double-checked locking to safely initialize the registrar when // we're running in multithreaded mode. - if (!PassRegistrarObj) + if (!PassRegistrarObj) { if (llvm_is_multithreaded()) { llvm_acquire_global_lock(); if (!PassRegistrarObj) { @@ -208,6 +208,7 @@ llvm_release_global_lock(); } else PassRegistrarObj = new PassRegistrar(); + } return PassRegistrarObj; } From howard0su at gmail.com Wed Jun 17 22:16:09 2009 From: howard0su at gmail.com (Howard Su) Date: Thu, 18 Jun 2009 11:16:09 +0800 Subject: [llvm-commits] [Patch] Fix build when disable thread support Message-ID: Index: RWMutex.cpp =================================================================== --- RWMutex.cpp (revision 73673) +++ RWMutex.cpp (working copy) @@ -23,7 +23,7 @@ // Define all methods as no-ops if threading is explicitly disabled namespace llvm { using namespace sys; -RWMutex::RWMutex( bool recursive) { } +RWMutex::RWMutex() { } RWMutex::~RWMutex() { } bool RWMutex::reader_acquire() { return true; } bool RWMutex::reader_release() { return true; } -- -Howard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090618/e3989897/attachment.html From howard0su at gmail.com Wed Jun 17 22:17:09 2009 From: howard0su at gmail.com (Howard Su) Date: Thu, 18 Jun 2009 11:17:09 +0800 Subject: [llvm-commits] [Patch] Fix Build for LiveInterval (forget include the datatype header) Message-ID: Index: LiveInterval.h =================================================================== --- LiveInterval.h (revision 73673) +++ LiveInterval.h (working copy) @@ -21,6 +21,7 @@ #ifndef LLVM_CODEGEN_LIVEINTERVAL_H #define LLVM_CODEGEN_LIVEINTERVAL_H +#include "llvm/Support/DataTypes.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Allocator.h" #include @@ -51,7 +52,7 @@ class VNInfo { private: - static const uint8_t HAS_PHI_KILL = 1, + static const uint8_t HAS_PHI_KILL = 1, REDEF_BY_EC = 1 << 1, IS_PHI_DEF = 1 << 2, IS_UNUSED = 1 << 3, -- -Howard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090618/61128511/attachment.html From clattner at apple.com Wed Jun 17 22:49:29 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 17 Jun 2009 20:49:29 -0700 Subject: [llvm-commits] [llvm] r73579 - in /llvm/trunk: Makefile.rules docs/MakefileGuide.html tools/llvmc/driver/Makefile In-Reply-To: References: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> <1245246876.6797.19.camel@vostro-1510.invia> Message-ID: <0936EF7D-A706-4333-9D26-DAD9EB35D1ED@apple.com> On Jun 17, 2009, at 6:41 PM, Mikhail Glushenkov wrote: > Hi Sylvere, > > Sylvere Teissier writes: > >> Furthermore, llvmc seems to be broken in my config. >> It doesn't contains clang and base plugins, or is it intentional ? > > Yep, this change broke llvmc for me too. > I'll see what needs to be done. The big part of the change was to change .o -> .a. If nothing references the .o file within the .a, it is quite possible that the code in the .a isn't being linked in... I'm sorry for the breakage, if you have any idea what the right fix is, I'd really appreciate help :) -Chris From xuzhongxing at gmail.com Wed Jun 17 23:11:44 2009 From: xuzhongxing at gmail.com (Zhongxing Xu) Date: Thu, 18 Jun 2009 04:11:44 -0000 Subject: [llvm-commits] [llvm] r73675 - /llvm/trunk/include/llvm/CodeGen/LiveInterval.h Message-ID: <200906180411.n5I4BiHl019351@zion.cs.uiuc.edu> Author: zhongxingxu Date: Wed Jun 17 23:11:43 2009 New Revision: 73675 URL: http://llvm.org/viewvc/llvm-project?rev=73675&view=rev Log: include header for uint8_t. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=73675&r1=73674&r2=73675&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Wed Jun 17 23:11:43 2009 @@ -23,6 +23,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/DataTypes.h" #include #include #include From resistor at mac.com Wed Jun 17 23:44:46 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 04:44:46 -0000 Subject: [llvm-commits] [llvm] r73680 - /llvm/trunk/lib/System/RWMutex.cpp Message-ID: <200906180444.n5I4ik6n021478@zion.cs.uiuc.edu> Author: resistor Date: Wed Jun 17 23:44:46 2009 New Revision: 73680 URL: http://llvm.org/viewvc/llvm-project?rev=73680&view=rev Log: Fix build when disable thread support. Patch by Howard Su. Modified: llvm/trunk/lib/System/RWMutex.cpp Modified: llvm/trunk/lib/System/RWMutex.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/RWMutex.cpp?rev=73680&r1=73679&r2=73680&view=diff ============================================================================== --- llvm/trunk/lib/System/RWMutex.cpp (original) +++ llvm/trunk/lib/System/RWMutex.cpp Wed Jun 17 23:44:46 2009 @@ -23,7 +23,7 @@ // Define all methods as no-ops if threading is explicitly disabled namespace llvm { using namespace sys; -RWMutex::RWMutex( bool recursive) { } +RWMutex::RWMutex() { } RWMutex::~RWMutex() { } bool RWMutex::reader_acquire() { return true; } bool RWMutex::reader_release() { return true; } From resistor at mac.com Wed Jun 17 23:45:00 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 17 Jun 2009 21:45:00 -0700 Subject: [llvm-commits] [Patch] Fix build when disable thread support In-Reply-To: References: Message-ID: <6E3B95D5-2457-4209-BEDB-C8D2DD28AC1F@mac.com> Committed. Thanks. --Owen On Jun 17, 2009, at 8:16 PM, Howard Su wrote: > Index: RWMutex.cpp > =================================================================== > --- RWMutex.cpp (revision 73673) > +++ RWMutex.cpp (working copy) > @@ -23,7 +23,7 @@ > // Define all methods as no-ops if threading is explicitly disabled > namespace llvm { > using namespace sys; > -RWMutex::RWMutex( bool recursive) { } > +RWMutex::RWMutex() { } > RWMutex::~RWMutex() { } > bool RWMutex::reader_acquire() { return true; } > bool RWMutex::reader_release() { return true; } > > > -- > -Howard > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2620 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090617/c46eaa2c/attachment.bin From sabre at nondot.org Wed Jun 17 23:56:53 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Jun 2009 04:56:53 -0000 Subject: [llvm-commits] [llvm] r73682 - /llvm/trunk/include/llvm/CodeGen/LiveInterval.h Message-ID: <200906180456.n5I4urYP022230@zion.cs.uiuc.edu> Author: lattner Date: Wed Jun 17 23:56:53 2009 New Revision: 73682 URL: http://llvm.org/viewvc/llvm-project?rev=73682&view=rev Log: Don't use int8_t, that requires DataTypes.h Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=73682&r1=73681&r2=73682&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Wed Jun 17 23:56:53 2009 @@ -23,7 +23,6 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Allocator.h" -#include "llvm/Support/DataTypes.h" #include #include #include @@ -52,13 +51,15 @@ class VNInfo { private: - static const uint8_t HAS_PHI_KILL = 1, - REDEF_BY_EC = 1 << 1, - IS_PHI_DEF = 1 << 2, - IS_UNUSED = 1 << 3, - IS_DEF_ACCURATE = 1 << 4; + enum { + HAS_PHI_KILL = 1, + REDEF_BY_EC = 1 << 1, + IS_PHI_DEF = 1 << 2, + IS_UNUSED = 1 << 3, + IS_DEF_ACCURATE = 1 << 4 + }; - uint8_t flags; + unsigned char flags; public: /// The ID number of this value. From nicolas.geoffray at lip6.fr Thu Jun 18 02:04:53 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 18 Jun 2009 09:04:53 +0200 Subject: [llvm-commits] [llvm] r73579 - in /llvm/trunk: Makefile.rules docs/MakefileGuide.html tools/llvmc/driver/Makefile In-Reply-To: <0936EF7D-A706-4333-9D26-DAD9EB35D1ED@apple.com> References: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> <1245246876.6797.19.camel@vostro-1510.invia> <0936EF7D-A706-4333-9D26-DAD9EB35D1ED@apple.com> Message-ID: <4A39E715.6090008@lip6.fr> Hi Chris, Chris Lattner wrote: > > The big part of the change was to change .o -> .a. If nothing > references the .o file within the .a, it is quite possible that the > code in the .a isn't being linked in... I'm sorry for the breakage, > if you have any idea what the right fix is, I'd really appreciate > help :) > So there are lots of functions in vmkit that are not used in vmkit's source code, but that will be used at runtime. With the .o -> .a change, these functions get indeed removed from the final executable, which makes vmkit crash because it can't find the functions. I see two options here: a) Generate a .o again. Have you left in Makefile.rules a way to generate .o instead of .a? b) Hack the source code to force these functions to be linked. I know llvm is doing that a lot in its header files, but I don't know what is the general rule for doing that. Do you have any advices? Thanks! Nicolas > -Chris > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From nicholas at mxc.ca Thu Jun 18 02:17:47 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 18 Jun 2009 00:17:47 -0700 Subject: [llvm-commits] teach jump-threading to handle br(icmp against non-constants) Message-ID: <4A39EA1B.3080507@mxc.ca> The attached patch teaches jump threading to handle the case where a PHI node is compared against an element inside the PHI node. Please review! There are still a couple of related optimizations this is missing: 1. we could create FCmpInst::isFalseWhenEqual and use that to handle some of the equivalent cases for float. Note that "true when equal" is not well defined for floats thanks to NaNs, but false should be fine. 2. we could handle this: jt: %x = phi i8 [%a, %bb1], [0, %bb2] %A = icmp ugt i8 %x, %b br i1 %A, label %rt, label %rf if we realized that "icmp ult i8 0, %b" is never true. There's a small battery of related tests. If someone does implement the above extensions, it would probably make sense to factor out "resultOfComparison" and put it somewhere more generally useful. Instcombine does these too, for example. Nick -------------- next part -------------- A non-text attachment was scrubbed... Name: jump-threading.patch Type: text/x-patch Size: 6183 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090618/f428eef4/attachment.bin From edwintorok at gmail.com Thu Jun 18 02:37:00 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Thu, 18 Jun 2009 10:37:00 +0300 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) In-Reply-To: <25637945-0AD3-4F9C-9C96-DB4AB9A4CCC7@apple.com> References: <4A393785.8090202@gmail.com> <6C8ECC3B-BE0E-4D05-92B4-926E9FF6CD8B@apple.com> <4A3955A9.4040300@gmail.com> <25637945-0AD3-4F9C-9C96-DB4AB9A4CCC7@apple.com> Message-ID: <4A39EE9C.5070406@gmail.com> On 2009-06-18 01:12, Dan Gohman wrote: > On Jun 17, 2009, at 1:44 PM, T?r?k Edwin wrote: > > > >> On 2009-06-17 23:25, Dan Gohman wrote: >> >> >>> On Jun 17, 2009, at 11:35 AM, T?r?k Edwin wrote: >>> >>> >>> >>> >>> >>> >>>> Hi, >>>> >>>> >>>> >>>> I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't >>>> >>>> folded, >>>> >>>> the attached patch folds this into: >>>> >>>> umax (zext t1 %X to %t0, zext t1 %Y to %t0). >>>> >>>> >>>> >>>> It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext >>>> t1 >>>> >>>> (umax (%X, %Y)) to %t0. >>>> >>>> >>>> >>>> zext is very often encountered in SCEV expressions on x86-64, since >>>> >>>> pointer indexes for GEP are i64. >>>> >>>> >>>> >>>> Thoughts? >>>> >>>> >>>> >>>> >>> Another question to ask is whether this kind of thing belongs in >>> >>> ScalarEvolution, or if it would be more appropriate for >>> >>> instcombine. Instcombine looks at all instructions in a program, >>> >>> while ScalarEvolution typically only looks at those related to >>> >>> loop iteration. Also, instcombine could more easily handle more >>> >>> generalized cases of this optimization, for example with umin. >>> >>> >>> >>> On the other hand, there are cases where it makes sense to do >>> >>> such simplifications in ScalarEvolution. Can you given an >>> >>> example where you're seeing this kind of code? >>> >>> >>> >>> >> It doesn't have much to do with code generation/optimization, but >> rather >> with analysis. >> I have a pass that tries to find buffer overflow bugs, doing that >> involves lots of umax() expressions. >> If I can move the zext out of umax I can decide quite early that an >> access is valid: >> >> int foo(unsigned n, unsigned i) >> { >> char *a = malloc(n); >> if (!a) >> return -1; >> if (i < n) >> a[i]=0; >> } >> > > Where does the umax come from in this code? I guess that you're > transforming it in some way; could you show what the code looks > like after the transformation? > %0 = malloc i8, i32 %n ; [#uses=2] %2 = zext i32 %i to i64 ; [#uses=1] %3 = getelementptr i8* %0, i64 %2 ; [#uses=1] %3 is '((zext i32 %i to i64) + %0' according to SCEV, %0 has size %n => offset is (zext i32 %i to i64), hence one of the safety conditions is i >= 0 && i < n. We already have i >= 0 since I treat all values as unsigned, so that leaves us with i < n: if ((zext i32 %n to i64) umax (zext i32 %i to i64)) == (zext i32 %i to i64) then access is always valid if ((zext i32 %n to i64) umax (zext i32 %i to i64)) == (zext i32 %n to i64) then access is always invalid Otherwise I use a solver to decide There are 2 more conditions (access size < size, offset + access_size < size) with similar expressions. As I said I could do the zext simplification in my pass only, but I thought this is something that would benefit SCEV(Expander) in general. Best regards, --Edwin From sanjiv.gupta at microchip.com Thu Jun 18 02:57:06 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Thu, 18 Jun 2009 13:27:06 +0530 Subject: [llvm-commits] [llvm] r73401 - /llvm/trunk/lib/Analysis/IVUsers.cpp In-Reply-To: <200906151838.n5FIcxns002287@zion.cs.uiuc.edu> References: <200906151838.n5FIcxns002287@zion.cs.uiuc.edu> Message-ID: <4A39F352.9090003@microchip.com> Dan Gohman wrote: > Author: djg > Date: Mon Jun 15 13:38:59 2009 > New Revision: 73401 > > URL: http://llvm.org/viewvc/llvm-project?rev=73401&view=rev > Log: > Code cleanups. getSCEVAtScope no longer uses SCEVCouldNotCompute. > > Modified: > llvm/trunk/lib/Analysis/IVUsers.cpp > > Modified: llvm/trunk/lib/Analysis/IVUsers.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IVUsers.cpp?rev=73401&r1=73400&r2=73401&view=diff > > ============================================================================== > --- llvm/trunk/lib/Analysis/IVUsers.cpp (original) > +++ llvm/trunk/lib/Analysis/IVUsers.cpp Mon Jun 15 13:38:59 2009 > @@ -120,9 +120,9 @@ > // Use getSCEVAtScope to attempt to simplify other loops out of > // the picture. > SCEVHandle AddRecStart = AddRec->getStart(); > - SCEVHandle BetterAddRecStart = SE->getSCEVAtScope(AddRecStart, UseLoop); > - if (!isa(BetterAddRecStart)) > - AddRecStart = BetterAddRecStart; > + AddRecStart = SE->getSCEVAtScope(AddRecStart, UseLoop); > + SCEVHandle AddRecStride = AddRec->getStepRecurrence(*SE); > + AddRecStride = SE->getSCEVAtScope(AddRecStride, UseLoop); > > Dan, Since you meant only code cleanup, the last line I think is left there by mistake as in the original code we had only one call to SE->getSCEVAtScope(AddRecStart, UseLoop); which is already there two lines above. - Sanjiv > // FIXME: If Start contains an SCEVAddRecExpr from a different loop, other > // than an outer loop of the current loop, reject it. LSR has no concept of > @@ -136,18 +136,18 @@ > > Start = SE->getAddExpr(Start, AddRecStart); > > - if (!isa(AddRec->getStepRecurrence(*SE))) { > - // If stride is an instruction, make sure it dominates the loop preheader. > - // Otherwise we could end up with a use before def situation. > + // If stride is an instruction, make sure it dominates the loop preheader. > + // Otherwise we could end up with a use before def situation. > + if (!isa(AddRecStride)) { > BasicBlock *Preheader = L->getLoopPreheader(); > - if (!AddRec->getStepRecurrence(*SE)->dominates(Preheader, DT)) > + if (!AddRecStride->dominates(Preheader, DT)) > return false; > > DOUT << "[" << L->getHeader()->getName() > << "] Variable stride: " << *AddRec << "\n"; > } > > - Stride = AddRec->getStepRecurrence(*SE); > + Stride = AddRecStride; > isSigned = isSExt; > return true; > } > @@ -326,7 +326,7 @@ > // Evaluate the expression out of the loop, if possible. > if (!L->contains(U.getUser()->getParent())) { > SCEVHandle ExitVal = SE->getSCEVAtScope(RetVal, L->getParentLoop()); > - if (!isa(ExitVal) && ExitVal->isLoopInvariant(L)) > + if (ExitVal->isLoopInvariant(L)) > RetVal = ExitVal; > } > // Promote the result to the type of the use. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From anton at korobeynikov.info Thu Jun 18 03:10:08 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 18 Jun 2009 12:10:08 +0400 Subject: [llvm-commits] [llvm] r73646 - /llvm/trunk/include/llvm/Support/IRBuilder.h In-Reply-To: <2AC709DE-1579-427A-8D43-B0B0546791FE@apple.com> References: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> <2AC709DE-1579-427A-8D43-B0B0546791FE@apple.com> Message-ID: Hi Chris > Anton, why isn't the caller and callee already getting the right > calling conv? ?This seems like the wrong fix, We have separate calling conv fields on, for example, Function and CallInst. That's why API user should put correct calling conv on CallInst during creation of such (see, for example, SimplifyCFGPass.cpp:ChangeToCall). By default CI's are created with C calling conv and in general we'll have calling conv mismatch between caller and callee if API user won't tune the calling conv of CI. SimplifyLibCalls pass uses IRBuilder to insert calls to strlen & friends. They can be already defined in the module with non-C calling convention, thus we need to put the same calling conv on CI also. I thought it's much safer to let IRBuilder to do this by default instead of letting each user to do this explicitly. Also, since custom CCs are not so frequent stuff, possible bugs due to CC mismatch might be pretty tricky to catch of we'll delegate tweaking of CC to API user. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From anton at korobeynikov.info Thu Jun 18 03:10:29 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 18 Jun 2009 12:10:29 +0400 Subject: [llvm-commits] [llvm] r73646 - /llvm/trunk/include/llvm/Support/IRBuilder.h In-Reply-To: <4A398185.7070800@wxs.nl> References: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> <4A398185.7070800@wxs.nl> Message-ID: Hi Frits > Shouldn't invokes do this too? Indeed! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From asl at math.spbu.ru Thu Jun 18 03:13:57 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Thu, 18 Jun 2009 08:13:57 -0000 Subject: [llvm-commits] [llvm] r73692 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200906180813.n5I8Dveh014358@zion.cs.uiuc.edu> Author: asl Date: Thu Jun 18 03:13:56 2009 New Revision: 73692 URL: http://llvm.org/viewvc/llvm-project?rev=73692&view=rev Log: Propagate calling conv for invokes too Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=73692&r1=73691&r2=73692&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Thu Jun 18 03:13:56 2009 @@ -154,8 +154,10 @@ InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, InputIterator ArgBegin, InputIterator ArgEnd, const char *Name = "") { - return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, - ArgBegin, ArgEnd), Name); + return Insert(TransferAttributes(InvokeInst::Create(Callee, + NormalDest, UnwindDest, + ArgBegin, ArgEnd), + Callee), Name); } UnwindInst *CreateUnwind() { From fvbommel at wxs.nl Thu Jun 18 03:22:39 2009 From: fvbommel at wxs.nl (Frits van Bommel) Date: Thu, 18 Jun 2009 10:22:39 +0200 Subject: [llvm-commits] [llvm] r73692 - /llvm/trunk/include/llvm/Support/IRBuilder.h In-Reply-To: <200906180813.n5I8Dveh014358@zion.cs.uiuc.edu> References: <200906180813.n5I8Dveh014358@zion.cs.uiuc.edu> Message-ID: <4A39F94F.1000907@wxs.nl> Anton Korobeynikov wrote: > Author: asl > Date: Thu Jun 18 03:13:56 2009 > New Revision: 73692 > > URL: http://llvm.org/viewvc/llvm-project?rev=73692&view=rev > Log: > Propagate calling conv for invokes too > --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) > +++ llvm/trunk/include/llvm/Support/IRBuilder.h Thu Jun 18 03:13:56 2009 > @@ -154,8 +154,10 @@ > InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, > BasicBlock *UnwindDest, InputIterator ArgBegin, > InputIterator ArgEnd, const char *Name = "") { > - return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, > - ArgBegin, ArgEnd), Name); > + return Insert(TransferAttributes(InvokeInst::Create(Callee, > + NormalDest, UnwindDest, > + ArgBegin, ArgEnd), > + Callee), Name); I thought your previous commit only created TransferAttributes for CallInst? From baldrick at free.fr Thu Jun 18 03:26:50 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 18 Jun 2009 10:26:50 +0200 Subject: [llvm-commits] [llvm] r73636 - /llvm/trunk/lib/VMCore/Pass.cpp In-Reply-To: <200906172116.n5HLGSsF005548@zion.cs.uiuc.edu> References: <200906172116.n5HLGSsF005548@zion.cs.uiuc.edu> Message-ID: <4A39FA4A.1020607@free.fr> Hi Owen, > + // Use double-checked locking to safely initialize the registrar when > + // we're running in multithreaded mode. > if (!PassRegistrarObj) > - PassRegistrarObj = new PassRegistrar(); > + if (llvm_is_multithreaded()) { > + llvm_acquire_global_lock(); > + if (!PassRegistrarObj) { > + PassRegistrar* tmp = new PassRegistrar(); > + sys::MemoryFence(); > + PassRegistrarObj = tmp; > + } > + llvm_release_global_lock(); > + } else > + PassRegistrarObj = new PassRegistrar(); usual style is to have {} around the else branch too. More seriously, I think you need an additional fence in the case when PassRegistrarObj is seen to be non-null at the start, to prevent subsequent loads from PassRegistrarObj being reordered and getting uninitialized values. To explain what I mean, consider the following. Processors 1 and 2 both have the value of the PassRegistrarObj pointer in cache. They also both have the memory corresponding to the malloced object in cache but in a different cache line. Initially the value of the pointer is null. Processor 1 mallocs some memory (memory is in a cache line, see above), initializes it (updates the values in its cache), and assigns the value to the PassRegistrarObj (in a different cache line). Now processor 2 comes along. If its cache line holding the PassRegistrarObj has been updated then it will see the new non-null value. Now it reads values from the malloced memory, but if this other cache line has not been synced with the other processor's yet then it will see uninitialized values. Of course you are going to say that sys::MemoryFence(); takes care of this. In fact it doesn't - both processors have to execute a memory barrier, not just one. In fact this is a general rule: if there is only one memory barrier then you are probably doing something wrong! The memory barrier for processor 1 means that it publishes information about which cache lines it wrote to the rest of the system. But other processors can (and do) ignore that if they have not been told themselves to not reorder reads (via a memory barrier). When processor 2 sees its memory barrier (missing in your code) then it will take a look at the published cache info and actually do something. Without a memory barrier it can read the cache lines in the order it likes. That said, most processors try to be helpful: when dereferencing a pointer they apparently do an implicit memory barrier to get the cache line of the pointee appropriately, so you tend not to see this. However it can happen on alpha - this caused all kind of pain in the linux kernel it seems. Ciao, Duncan. PS: Take a look at http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf and notice the two memory barriers on page 12. From asl at math.spbu.ru Thu Jun 18 03:30:58 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Thu, 18 Jun 2009 08:30:58 -0000 Subject: [llvm-commits] [llvm] r73693 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200906180830.n5I8UwM2015329@zion.cs.uiuc.edu> Author: asl Date: Thu Jun 18 03:30:57 2009 New Revision: 73693 URL: http://llvm.org/viewvc/llvm-project?rev=73693&view=rev Log: Forgot to commit this hunk Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=73693&r1=73692&r2=73693&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Thu Jun 18 03:30:57 2009 @@ -601,6 +601,18 @@ return CI; } + InvokeInst *TransferAttributes(InvokeInst *II, const Value* Callee) const { + if (const GlobalAlias *GA = dyn_cast(Callee)) + Callee = GA->getAliasedGlobal(); + + if (const Function *F = dyn_cast(Callee)) { + II->setCallingConv(F->getCallingConv()); + II->setAttributes(F->getAttributes()); + } + + return II; + } + CallInst *CreateCall(Value *Callee, const char *Name = "") { return Insert(TransferAttributes(CallInst::Create(Callee), Callee), Name); } From baldrick at free.fr Thu Jun 18 05:19:22 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 18 Jun 2009 12:19:22 +0200 Subject: [llvm-commits] Cyclic dependencies between LLVM libraries with debug builds Message-ID: <4A3A14AA.4020105@free.fr> If I configure without any options (equivalent to --disable-optimized --enable-assertions) on x64-64 linux then the build fails with: llvm[1]: Checking for cyclic dependencies between LLVM libraries. find-cycles.pl: Circular dependency between *.a files: find-cycles.pl: libLLVMSparcAsmPrinter.a libLLVMSparcCodeGen.a find-cycles.pl: Circular dependency between *.a files: find-cycles.pl: libLLVMCellSPUAsmPrinter.a libLLVMCellSPUCodeGen.a find-cycles.pl: Circular dependency between *.a files: find-cycles.pl: libLLVMAlphaAsmPrinter.a libLLVMAlphaCodeGen.a find-cycles.pl: Circular dependency between *.a files: find-cycles.pl: libLLVMIA64AsmPrinter.a libLLVMIA64CodeGen.a Any ideas? Ciao, Duncan. From benny.kra at googlemail.com Thu Jun 18 06:31:53 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 18 Jun 2009 13:31:53 +0200 Subject: [llvm-commits] [PATCH] Remove GNU particuliers from NewNightlyTest.pl , more system portable. Message-ID: Sorry, but seeing this ugly perl code almost made my cry (not your fault though). So I decided to port it to File::Find which is part of perl's standard library. This gives us some advantages: 1. portability: File::Find works even on windows ;) 2. performance: the new code is >100 times faster on my machine. The slowdown is probably caused by backtracking in the old regex 3. cleanup: there were lots of duplicated code -------------- next part -------------- A non-text attachment was scrubbed... Name: nightlyfind.patch Type: application/octet-stream Size: 2027 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090618/fca384df/attachment.obj -------------- next part -------------- From st at invia.fr Thu Jun 18 06:56:18 2009 From: st at invia.fr (Sylvere Teissier) Date: Thu, 18 Jun 2009 13:56:18 +0200 Subject: [llvm-commits] Cyclic dependencies between LLVM libraries with debug builds In-Reply-To: <4A3A14AA.4020105@free.fr> References: <4A3A14AA.4020105@free.fr> Message-ID: <1245326178.5496.1.camel@vostro-1510.invia> Le jeudi 18 juin 2009 ? 12:19 +0200, Duncan Sands a ?crit : > If I configure without any options (equivalent to --disable-optimized > --enable-assertions) on x64-64 linux then the build fails with: > > llvm[1]: Checking for cyclic dependencies between LLVM libraries. > find-cycles.pl: Circular dependency between *.a files: > find-cycles.pl: libLLVMSparcAsmPrinter.a libLLVMSparcCodeGen.a > find-cycles.pl: Circular dependency between *.a files: > find-cycles.pl: libLLVMCellSPUAsmPrinter.a libLLVMCellSPUCodeGen.a > find-cycles.pl: Circular dependency between *.a files: > find-cycles.pl: libLLVMAlphaAsmPrinter.a libLLVMAlphaCodeGen.a > find-cycles.pl: Circular dependency between *.a files: > find-cycles.pl: libLLVMIA64AsmPrinter.a libLLVMIA64CodeGen.a > > Any ideas? Maybe it is related with r73579 changes. From the.dead.shall.rise at gmail.com Thu Jun 18 05:49:18 2009 From: the.dead.shall.rise at gmail.com (Mikhail Glushenkov) Date: Thu, 18 Jun 2009 10:49:18 +0000 (UTC) Subject: [llvm-commits] =?utf-8?q?=5Bllvm=5D_r73579_-_in=09/llvm/trunk=3A?= =?utf-8?q?=09Makefile=2Erules=09docs/MakefileGuide=2Ehtml=09tools/?= =?utf-8?q?llvmc/driver/Makefile?= References: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> <1245246876.6797.19.camel@vostro-1510.invia> <0936EF7D-A706-4333-9D26-DAD9EB35D1ED@apple.com> Message-ID: Hi Chris, Chris Lattner writes: > I'm sorry for the breakage, > if you have any idea what the right fix is, I'd really appreciate > help :) I'm working on a fix. From resistor at mac.com Thu Jun 18 11:08:33 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 16:08:33 -0000 Subject: [llvm-commits] [llvm] r73701 - /llvm/trunk/lib/VMCore/Pass.cpp Message-ID: <200906181608.n5IG8a3R000716@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 11:08:27 2009 New Revision: 73701 URL: http://llvm.org/viewvc/llvm-project?rev=73701&view=rev Log: As pointed out by Duncan, I accidentally dropped the first MemoryFence of the double-checked locking pattern here. Modified: llvm/trunk/lib/VMCore/Pass.cpp Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=73701&r1=73700&r2=73701&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Thu Jun 18 11:08:27 2009 @@ -197,17 +197,21 @@ // Use double-checked locking to safely initialize the registrar when // we're running in multithreaded mode. - if (!PassRegistrarObj) { + PassRegistrar* tmp = PassRegistrarObj; + sys::MemoryFence(); + if (!tmp) { if (llvm_is_multithreaded()) { llvm_acquire_global_lock(); - if (!PassRegistrarObj) { - PassRegistrar* tmp = new PassRegistrar(); + tmp = PassRegistrarObj; + if (!tmp) { + tmp = new PassRegistrar(); sys::MemoryFence(); PassRegistrarObj = tmp; } llvm_release_global_lock(); - } else + } else { PassRegistrarObj = new PassRegistrar(); + } } return PassRegistrarObj; } From resistor at mac.com Thu Jun 18 11:17:50 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 16:17:50 -0000 Subject: [llvm-commits] [llvm] r73703 - /llvm/trunk/lib/VMCore/Type.cpp Message-ID: <200906181617.n5IGHqpk001207@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 11:17:42 2009 New Revision: 73703 URL: http://llvm.org/viewvc/llvm-project?rev=73703&view=rev Log: Fix the double checked locking in this file too. Modified: llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73703&r1=73702&r2=73703&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Thu Jun 18 11:17:42 2009 @@ -455,12 +455,14 @@ // that will never get resolved, thus will always be abstract. static Type *AlwaysOpaqueTy = 0; static PATypeHolder* Holder = 0; - if (!AlwaysOpaqueTy) { + Type *tmp = AlwaysOpaqueTy; + sys::MemoryFence(); + if (!tmp) { if (llvm_is_multithreaded()) { llvm_acquire_global_lock(); - - if (!AlwaysOpaqueTy) { - Type *tmp = OpaqueType::get(); + tmp = AlwaysOpaqueTy; + if (!tmp) { + tmp = OpaqueType::get(); PATypeHolder* tmp2 = new PATypeHolder(AlwaysOpaqueTy); sys::MemoryFence(); AlwaysOpaqueTy = tmp; From gohman at apple.com Thu Jun 18 11:24:47 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Jun 2009 16:24:47 -0000 Subject: [llvm-commits] [llvm] r73704 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200906181624.n5IGOlmM001522@zion.cs.uiuc.edu> Author: djg Date: Thu Jun 18 11:24:47 2009 New Revision: 73704 URL: http://llvm.org/viewvc/llvm-project?rev=73704&view=rev Log: Update a comment to reflect the code. 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=73704&r1=73703&r2=73704&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Jun 18 11:24:47 2009 @@ -778,8 +778,7 @@ if (const SCEVZeroExtendExpr *SZ = dyn_cast(Op)) return getTruncateOrZeroExtend(SZ->getOperand(), Ty); - // If the input value is a chrec scev made out of constants, truncate - // all of the constants. + // If the input value is a chrec scev, truncate the chrec's operands. if (const SCEVAddRecExpr *AddRec = dyn_cast(Op)) { SmallVector Operands; for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i) From gohman at apple.com Thu Jun 18 11:30:22 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Jun 2009 16:30:22 -0000 Subject: [llvm-commits] [llvm] r73705 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/trunc-mask-ext.ll Message-ID: <200906181630.n5IGUMHE001836@zion.cs.uiuc.edu> Author: djg Date: Thu Jun 18 11:30:21 2009 New Revision: 73705 URL: http://llvm.org/viewvc/llvm-project?rev=73705&view=rev Log: Generalize the zext(trunc(t) & C) instcombine to work even with C is not a low-bits mask, and add a similar instcombine for zext((trunc(t) & C) ^ C). Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/trunc-mask-ext.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=73705&r1=73704&r2=73705&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu Jun 18 11:30:21 2009 @@ -8564,20 +8564,33 @@ } } - // zext(trunc(t) & C) -> (t & C) if C is a mask. + // zext(trunc(t) & C) -> (t & zext(C)). if (SrcI && SrcI->getOpcode() == Instruction::And && SrcI->hasOneUse()) if (ConstantInt *C = dyn_cast(SrcI->getOperand(1))) if (TruncInst *TI = dyn_cast(SrcI->getOperand(0))) { Value *TI0 = TI->getOperand(0); - if (TI0->getType() == CI.getType()) { - unsigned TO = C->getValue().countTrailingOnes(); - if (APIntOps::isMask(TO, C->getValue())) - return - BinaryOperator::Create(Instruction::And, TI0, - ConstantExpr::getZExt(C, CI.getType())); - } + if (TI0->getType() == CI.getType()) + return + BinaryOperator::CreateAnd(TI0, + ConstantExpr::getZExt(C, CI.getType())); } + // zext((trunc(t) & C) ^ C) -> ((t & zext(C)) ^ zext(C)). + if (SrcI && SrcI->getOpcode() == Instruction::Xor && SrcI->hasOneUse()) + if (ConstantInt *C = dyn_cast(SrcI->getOperand(1))) + if (BinaryOperator *And = dyn_cast(SrcI->getOperand(0))) + if (And->getOpcode() == Instruction::And && And->hasOneUse() && + And->getOperand(1) == C) + if (TruncInst *TI = dyn_cast(And->getOperand(0))) { + Value *TI0 = TI->getOperand(0); + if (TI0->getType() == CI.getType()) { + Constant *ZC = ConstantExpr::getZExt(C, CI.getType()); + Instruction *NewAnd = BinaryOperator::CreateAnd(TI0, ZC, "tmp"); + InsertNewInstBefore(NewAnd, *And); + return BinaryOperator::CreateXor(NewAnd, ZC); + } + } + return 0; } Modified: llvm/trunk/test/Transforms/InstCombine/trunc-mask-ext.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/trunc-mask-ext.ll?rev=73705&r1=73704&r2=73705&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/trunc-mask-ext.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/trunc-mask-ext.ll Thu Jun 18 11:30:21 2009 @@ -2,7 +2,7 @@ ; RUN: not grep zext %t ; RUN: not grep sext %t -; Instcombine should be able to eliminate both ext casts. +; Instcombine should be able to eliminate all of these ext casts. declare void @use(i32) @@ -21,3 +21,18 @@ call void @use(i32 %b) ret i64 %d } +define i64 @goo(i64 %a) { + %b = trunc i64 %a to i32 + %c = and i32 %b, 8 + %d = zext i32 %c to i64 + call void @use(i32 %b) + ret i64 %d +} +define i64 @hoo(i64 %a) { + %b = trunc i64 %a to i32 + %c = and i32 %b, 8 + %x = xor i32 %c, 8 + %d = zext i32 %x to i64 + call void @use(i32 %b) + ret i64 %d +} From gohman at apple.com Thu Jun 18 11:54:11 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Jun 2009 16:54:11 -0000 Subject: [llvm-commits] [llvm] r73706 - in /llvm/trunk: include/llvm/Analysis/IVUsers.h lib/Analysis/IVUsers.cpp lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/iv-users-in-other-loops.ll test/Transforms/IndVarSimplify/masked-iv.ll test/Transforms/IndVarSimplify/shrunk-constant.ll Message-ID: <200906181654.n5IGsC23003339@zion.cs.uiuc.edu> Author: djg Date: Thu Jun 18 11:54:06 2009 New Revision: 73706 URL: http://llvm.org/viewvc/llvm-project?rev=73706&view=rev Log: Remove the code from IVUsers that attempted to handle casted induction variables in cases where the cast isn't foldable. It ended up being a pessimization in many cases. This could be fixed, but it would require a bunch of complicated code in IVUsers' clients. The advantages of this approach aren't visible enough to justify it at this time. Modified: llvm/trunk/include/llvm/Analysis/IVUsers.h llvm/trunk/lib/Analysis/IVUsers.cpp llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp llvm/trunk/test/CodeGen/X86/iv-users-in-other-loops.ll llvm/trunk/test/Transforms/IndVarSimplify/masked-iv.ll llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll Modified: llvm/trunk/include/llvm/Analysis/IVUsers.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/IVUsers.h?rev=73706&r1=73705&r2=73706&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/IVUsers.h (original) +++ llvm/trunk/include/llvm/Analysis/IVUsers.h Thu Jun 18 11:54:06 2009 @@ -35,9 +35,9 @@ public: IVStrideUse(IVUsersOfOneStride *parent, const SCEVHandle &offset, - Instruction* U, Value *O, bool issigned) + Instruction* U, Value *O) : CallbackVH(U), Parent(parent), Offset(offset), - OperandValToReplace(O), IsSigned(issigned), + OperandValToReplace(O), IsUseOfPostIncrementedValue(false) { } @@ -57,8 +57,7 @@ /// getOffset - Return the offset to add to a theoeretical induction /// variable that starts at zero and counts up by the stride to compute - /// the value for the use. This always has the same type as the stride, - /// which may need to be casted to match the type of the use. + /// the value for the use. This always has the same type as the stride. SCEVHandle getOffset() const { return Offset; } /// setOffset - Assign a new offset to this use. @@ -78,13 +77,6 @@ OperandValToReplace = Op; } - /// isSigned - The stride (and thus also the Offset) of this use may be in - /// a narrower type than the use itself (OperandValToReplace->getType()). - /// When this is the case, isSigned() indicates whether the IV expression - /// should be signed-extended instead of zero-extended to fit the type of - /// the use. - bool isSigned() const { return IsSigned; } - /// isUseOfPostIncrementedValue - True if this should use the /// post-incremented version of this IV, not the preincremented version. /// This can only be set in special cases, such as the terminating setcc @@ -110,10 +102,6 @@ /// that this IVStrideUse is representing. WeakVH OperandValToReplace; - /// IsSigned - Determines whether the replacement value is sign or - /// zero extended to the type of the use. - bool IsSigned; - /// IsUseOfPostIncrementedValue - True if this should use the /// post-incremented version of this IV, not the preincremented version. bool IsUseOfPostIncrementedValue; @@ -170,9 +158,8 @@ /// initial value and the operand that uses the IV. ilist Users; - void addUser(const SCEVHandle &Offset,Instruction *User, Value *Operand, - bool isSigned) { - Users.push_back(new IVStrideUse(this, Offset, User, Operand, isSigned)); + void addUser(const SCEVHandle &Offset, Instruction *User, Value *Operand) { + Users.push_back(new IVStrideUse(this, Offset, User, Operand)); } }; Modified: llvm/trunk/lib/Analysis/IVUsers.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IVUsers.cpp?rev=73706&r1=73705&r2=73706&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IVUsers.cpp (original) +++ llvm/trunk/lib/Analysis/IVUsers.cpp Thu Jun 18 11:54:06 2009 @@ -82,11 +82,8 @@ /// outer loop of the current loop. static bool getSCEVStartAndStride(const SCEVHandle &SH, Loop *L, Loop *UseLoop, SCEVHandle &Start, SCEVHandle &Stride, - bool &isSigned, ScalarEvolution *SE, DominatorTree *DT) { SCEVHandle TheAddRec = Start; // Initialize to zero. - bool isSExt = false; - bool isZExt = false; // If the outer level is an AddExpr, the operands are all start values except // for a nested AddRecExpr. @@ -101,13 +98,6 @@ } else { Start = SE->getAddExpr(Start, AE->getOperand(i)); } - - } else if (const SCEVZeroExtendExpr *Z = dyn_cast(SH)) { - TheAddRec = Z->getOperand(); - isZExt = true; - } else if (const SCEVSignExtendExpr *S = dyn_cast(SH)) { - TheAddRec = S->getOperand(); - isSExt = true; } else if (isa(SH)) { TheAddRec = SH; } else { @@ -131,9 +121,6 @@ if (containsAddRecFromDifferentLoop(AddRecStart, L)) return false; - if (isSExt || isZExt) - Start = SE->getTruncateExpr(Start, AddRec->getType()); - Start = SE->getAddExpr(Start, AddRecStart); // If stride is an instruction, make sure it dominates the loop preheader. @@ -148,7 +135,6 @@ } Stride = AddRecStride; - isSigned = isSExt; return true; } @@ -218,9 +204,8 @@ Loop *UseLoop = LI->getLoopFor(I->getParent()); SCEVHandle Start = SE->getIntegerSCEV(0, ISE->getType()); SCEVHandle Stride = Start; - bool isSigned = false; // Arbitrary initial value - pacifies compiler. - if (!getSCEVStartAndStride(ISE, L, UseLoop, Start, Stride, isSigned, SE, DT)) + if (!getSCEVStartAndStride(ISE, L, UseLoop, Start, Stride, SE, DT)) return false; // Non-reducible symbolic expression, bail out. SmallPtrSet UniqueUsers; @@ -271,11 +256,11 @@ // The value used will be incremented by the stride more than we are // expecting, so subtract this off. SCEVHandle NewStart = SE->getMinusSCEV(Start, Stride); - StrideUses->addUser(NewStart, User, I, isSigned); + StrideUses->addUser(NewStart, User, I); StrideUses->Users.back().setIsUseOfPostIncrementedValue(true); DOUT << " USING POSTINC SCEV, START=" << *NewStart<< "\n"; } else { - StrideUses->addUser(Start, User, I, isSigned); + StrideUses->addUser(Start, User, I); } } } @@ -312,7 +297,6 @@ /// getReplacementExpr - Return a SCEV expression which computes the /// value of the OperandValToReplace of the given IVStrideUse. SCEVHandle IVUsers::getReplacementExpr(const IVStrideUse &U) const { - const Type *UseTy = U.getOperandValToReplace()->getType(); // Start with zero. SCEVHandle RetVal = SE->getIntegerSCEV(0, U.getParent()->Stride->getType()); // Create the basic add recurrence. @@ -329,14 +313,6 @@ if (ExitVal->isLoopInvariant(L)) RetVal = ExitVal; } - // Promote the result to the type of the use. - if (SE->getTypeSizeInBits(RetVal->getType()) != - SE->getTypeSizeInBits(UseTy)) { - if (U.isSigned()) - RetVal = SE->getSignExtendExpr(RetVal, UseTy); - else - RetVal = SE->getZeroExtendExpr(RetVal, UseTy); - } return RetVal; } Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=73706&r1=73705&r2=73706&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Thu Jun 18 11:54:06 2009 @@ -336,13 +336,6 @@ /// EmittedBase. Value *OperandValToReplace; - /// isSigned - The stride (and thus also the Base) of this use may be in - /// a narrower type than the use itself (OperandValToReplace->getType()). - /// When this is the case, the isSigned field indicates whether the - /// IV expression should be signed-extended instead of zero-extended to - /// fit the type of the use. - bool isSigned; - /// Imm - The immediate value that should be added to the base immediately /// before Inst, because it will be folded into the imm field of the /// instruction. This is also sometimes used for loop-variant values that @@ -363,7 +356,6 @@ BasedUser(IVStrideUse &IVSU, ScalarEvolution *se) : SE(se), Base(IVSU.getOffset()), Inst(IVSU.getUser()), OperandValToReplace(IVSU.getOperandValToReplace()), - isSigned(IVSU.isSigned()), Imm(SE->getIntegerSCEV(0, Base->getType())), isUseOfPostIncrementedValue(IVSU.isUseOfPostIncrementedValue()) {} @@ -428,11 +420,6 @@ NewValSCEV = SE->getAddExpr(NewValSCEV, Imm); } - if (isSigned) - NewValSCEV = SE->getTruncateOrSignExtend(NewValSCEV, Ty); - else - NewValSCEV = SE->getTruncateOrZeroExtend(NewValSCEV, Ty); - return Rewriter.expandCodeFor(NewValSCEV, Ty, IP); } @@ -2047,7 +2034,7 @@ OldCond->replaceAllUsesWith(Cond); OldCond->eraseFromParent(); - IU->IVUsesByStride[*NewStride]->addUser(NewOffset, Cond, NewCmpLHS, false); + IU->IVUsesByStride[*NewStride]->addUser(NewOffset, Cond, NewCmpLHS); CondUse = &IU->IVUsesByStride[*NewStride]->Users.back(); CondStride = NewStride; ++NumEliminated; @@ -2397,8 +2384,7 @@ // Clone the IVUse, as the old use still exists! IU->IVUsesByStride[*CondStride]->addUser(CondUse->getOffset(), Cond, - CondUse->getOperandValToReplace(), - false); + CondUse->getOperandValToReplace()); CondUse = &IU->IVUsesByStride[*CondStride]->Users.back(); } } Modified: llvm/trunk/test/CodeGen/X86/iv-users-in-other-loops.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/iv-users-in-other-loops.ll?rev=73706&r1=73705&r2=73706&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/iv-users-in-other-loops.ll (original) +++ llvm/trunk/test/CodeGen/X86/iv-users-in-other-loops.ll Thu Jun 18 11:54:06 2009 @@ -1,11 +1,11 @@ ; RUN: llvm-as < %s | llc -march=x86-64 -f -o %t ; RUN: grep inc %t | count 1 ; RUN: grep dec %t | count 2 -; RUN: grep addq %t | count 8 -; RUN: grep addb %t | count 2 -; RUN: grep leaq %t | count 12 -; RUN: grep leal %t | count 2 -; RUN: grep movq %t | count 4 +; RUN: grep addq %t | count 13 +; RUN: not grep addb %t +; RUN: grep leaq %t | count 8 +; RUN: grep leal %t | count 4 +; RUN: grep movq %t | count 5 ; IV users in each of the loops from other loops shouldn't cause LSR ; to insert new induction variables. Previously it would create a Modified: llvm/trunk/test/Transforms/IndVarSimplify/masked-iv.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/masked-iv.ll?rev=73706&r1=73705&r2=73706&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/masked-iv.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/masked-iv.ll Thu Jun 18 11:54:06 2009 @@ -1,4 +1,6 @@ -; RUN: llvm-as < %s | opt -indvars | llvm-dis | grep trunc | count 1 +; RUN: llvm-as < %s | opt -indvars | llvm-dis > %t +; RUN: not grep trunc %t +; RUN: grep and %t | count 1 ; Indvars should do the IV arithmetic in the canonical IV type (i64), ; and only use one truncation. Modified: llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll?rev=73706&r1=73705&r2=73706&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/shrunk-constant.ll Thu Jun 18 11:54:06 2009 @@ -1,4 +1,5 @@ -; RUN: llvm-as < %s | opt -iv-users -analyze -disable-output | grep store +; RUN: llvm-as < %s | opt -scalar-evolution -analyze -disable-output \ +; RUN: | grep {\\--> (zext i4 {-7,+,-8} to i32)} define fastcc void @foo() nounwind { entry: From resistor at mac.com Thu Jun 18 11:54:52 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 16:54:52 -0000 Subject: [llvm-commits] [llvm] r73707 - in /llvm/trunk: include/llvm/Support/ManagedStatic.h include/llvm/Support/Threading.h include/llvm/System/Threading.h lib/Support/Threading.cpp lib/System/Threading.cpp lib/VMCore/Constants.cpp lib/VMCore/Function.cpp lib/VMCore/LeakDetector.cpp lib/VMCore/Pass.cpp lib/VMCore/PassManager.cpp lib/VMCore/Type.cpp lib/VMCore/TypeSymbolTable.cpp lib/VMCore/Value.cpp Message-ID: <200906181654.n5IGsr0P003408@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 11:54:52 2009 New Revision: 73707 URL: http://llvm.org/viewvc/llvm-project?rev=73707&view=rev Log: Move Threading.[h|cpp] from Support to System. Added: llvm/trunk/include/llvm/System/Threading.h - copied, changed from r73700, llvm/trunk/include/llvm/Support/Threading.h llvm/trunk/lib/System/Threading.cpp - copied, changed from r73700, llvm/trunk/lib/Support/Threading.cpp Removed: llvm/trunk/include/llvm/Support/Threading.h llvm/trunk/lib/Support/Threading.cpp Modified: llvm/trunk/include/llvm/Support/ManagedStatic.h llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Function.cpp llvm/trunk/lib/VMCore/LeakDetector.cpp llvm/trunk/lib/VMCore/Pass.cpp llvm/trunk/lib/VMCore/PassManager.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/lib/VMCore/TypeSymbolTable.cpp llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/include/llvm/Support/ManagedStatic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ManagedStatic.h?rev=73707&r1=73706&r2=73707&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ManagedStatic.h (original) +++ llvm/trunk/include/llvm/Support/ManagedStatic.h Thu Jun 18 11:54:52 2009 @@ -15,7 +15,7 @@ #define LLVM_SUPPORT_MANAGED_STATIC_H #include "llvm/System/Atomic.h" -#include "llvm/Support/Threading.h" +#include "llvm/System/Threading.h" namespace llvm { Removed: llvm/trunk/include/llvm/Support/Threading.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Threading.h?rev=73706&view=auto ============================================================================== --- llvm/trunk/include/llvm/Support/Threading.h (original) +++ llvm/trunk/include/llvm/Support/Threading.h (removed) @@ -1,45 +0,0 @@ -//===-- llvm/Support/Threading.h - Control multithreading mode --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// TThis file defines llvm_start_multithreaded() and friends. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_THREADING_H -#define LLVM_SUPPORT_THREADING_H - -namespace llvm { - /// llvm_start_multithreaded - Allocate and initialize structures needed to - /// make LLVM safe for multithreading. The return value indicates whether - /// multithreaded initialization succeeded. LLVM will still be operational - /// on "failed" return, and will still be safe for hosting threading - /// applications in the JIT, but will not be safe for concurrent calls to the - /// LLVM APIs. - /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS. - bool llvm_start_multithreaded(); - - /// llvm_stop_multithreaded - Deallocate structures necessary to make LLVM - /// safe for multithreading. - /// THIS MUST EXECUTE IN ISOLATION FROM ALL OTHER LLVM API CALLS. - void llvm_stop_multithreaded(); - - /// llvm_is_multithreaded - Check whether LLVM is executing in thread-safe - /// mode or not. - bool llvm_is_multithreaded(); - - /// acquire_global_lock - Acquire the global lock. This is a no-op if called - /// before llvm_start_multithreaded(). - void llvm_acquire_global_lock(); - - /// release_global_lock - Release the global lock. This is a no-op if called - /// before llvm_start_multithreaded(). - void llvm_release_global_lock(); -} - -#endif Copied: llvm/trunk/include/llvm/System/Threading.h (from r73700, llvm/trunk/include/llvm/Support/Threading.h) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Threading.h?p2=llvm/trunk/include/llvm/System/Threading.h&p1=llvm/trunk/include/llvm/Support/Threading.h&r1=73700&r2=73707&rev=73707&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Threading.h (original) +++ llvm/trunk/include/llvm/System/Threading.h Thu Jun 18 11:54:52 2009 @@ -1,4 +1,4 @@ -//===-- llvm/Support/Threading.h - Control multithreading mode --*- C++ -*-===// +//===-- llvm/System/Threading.h - Control multithreading mode --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_THREADING_H -#define LLVM_SUPPORT_THREADING_H +#ifndef LLVM_SYSTEM_THREADING_H +#define LLVM_SYSTEM_THREADING_H namespace llvm { /// llvm_start_multithreaded - Allocate and initialize structures needed to Removed: llvm/trunk/lib/Support/Threading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Threading.cpp?rev=73706&view=auto ============================================================================== --- llvm/trunk/lib/Support/Threading.cpp (original) +++ llvm/trunk/lib/Support/Threading.cpp (removed) @@ -1,63 +0,0 @@ -//===-- llvm/Support/Threading.cpp- Control multithreading mode --*- C++ -*-==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements llvm_start_multithreaded() and friends. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/Threading.h" -#include "llvm/System/Atomic.h" -#include "llvm/System/Mutex.h" -#include - -using namespace llvm; - -static bool multithreaded_mode = false; - -static sys::Mutex* global_lock = 0; - -bool llvm::llvm_start_multithreaded() { -#ifdef LLVM_MULTITHREADED - assert(!multithreaded_mode && "Already multithreaded!"); - multithreaded_mode = true; - global_lock = new sys::Mutex(true); - - // We fence here to ensure that all initialization is complete BEFORE we - // return from llvm_start_multithreaded(). - sys::MemoryFence(); - return true; -#else - return false; -#endif -} - -void llvm::llvm_stop_multithreaded() { -#ifdef LLVM_MULTITHREADED - assert(multithreaded_mode && "Not currently multithreaded!"); - - // We fence here to insure that all threaded operations are complete BEFORE we - // return from llvm_stop_multithreaded(). - sys::MemoryFence(); - - multithreaded_mode = false; - delete global_lock; -#endif -} - -bool llvm::llvm_is_multithreaded() { - return multithreaded_mode; -} - -void llvm::llvm_acquire_global_lock() { - if (multithreaded_mode) global_lock->acquire(); -} - -void llvm::llvm_release_global_lock() { - if (multithreaded_mode) global_lock->release(); -} Copied: llvm/trunk/lib/System/Threading.cpp (from r73700, llvm/trunk/lib/Support/Threading.cpp) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Threading.cpp?p2=llvm/trunk/lib/System/Threading.cpp&p1=llvm/trunk/lib/Support/Threading.cpp&r1=73700&r2=73707&rev=73707&view=diff ============================================================================== --- llvm/trunk/lib/Support/Threading.cpp (original) +++ llvm/trunk/lib/System/Threading.cpp Thu Jun 18 11:54:52 2009 @@ -1,4 +1,4 @@ -//===-- llvm/Support/Threading.cpp- Control multithreading mode --*- C++ -*-==// +//===-- llvm/System/Threading.cpp- Control multithreading mode --*- C++ -*-==// // // The LLVM Compiler Infrastructure // @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Support/Threading.h" +#include "llvm/System/Threading.h" #include "llvm/System/Atomic.h" #include "llvm/System/Mutex.h" #include Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73707&r1=73706&r2=73707&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Thu Jun 18 11:54:52 2009 @@ -25,8 +25,8 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" -#include "llvm/Support/Threading.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=73707&r1=73706&r2=73707&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Thu Jun 18 11:54:52 2009 @@ -18,8 +18,8 @@ #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/StringPool.h" -#include "llvm/Support/Threading.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include "SymbolTableListTraitsImpl.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringExtras.h" Modified: llvm/trunk/lib/VMCore/LeakDetector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LeakDetector.cpp?rev=73707&r1=73706&r2=73707&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LeakDetector.cpp (original) +++ llvm/trunk/lib/VMCore/LeakDetector.cpp Thu Jun 18 11:54:52 2009 @@ -16,8 +16,8 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Streams.h" -#include "llvm/Support/Threading.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include "llvm/Value.h" using namespace llvm; Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=73707&r1=73706&r2=73707&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Thu Jun 18 11:54:52 2009 @@ -19,8 +19,8 @@ #include "llvm/ModuleProvider.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Threading.h" #include "llvm/System/Atomic.h" +#include "llvm/System/Threading.h" #include #include #include Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=73707&r1=73706&r2=73707&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Thu Jun 18 11:54:52 2009 @@ -20,8 +20,8 @@ #include "llvm/Support/Streams.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Threading.h" #include "llvm/System/Mutex.h" +#include "llvm/System/Threading.h" #include "llvm/Analysis/Dominators.h" #include "llvm-c/Core.h" #include Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73707&r1=73706&r2=73707&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Thu Jun 18 11:54:52 2009 @@ -23,9 +23,9 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Threading.h" #include "llvm/System/Mutex.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include #include using namespace llvm; Modified: llvm/trunk/lib/VMCore/TypeSymbolTable.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/TypeSymbolTable.cpp?rev=73707&r1=73706&r2=73707&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/TypeSymbolTable.cpp (original) +++ llvm/trunk/lib/VMCore/TypeSymbolTable.cpp Thu Jun 18 11:54:52 2009 @@ -16,8 +16,8 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Streams.h" -#include "llvm/Support/Threading.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include using namespace llvm; Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=73707&r1=73706&r2=73707&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Thu Jun 18 11:54:52 2009 @@ -21,9 +21,9 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/Threading.h" #include "llvm/Support/ValueHandle.h" #include "llvm/System/RWMutex.h" +#include "llvm/System/Threading.h" #include "llvm/ADT/DenseMap.h" #include using namespace llvm; From clattner at apple.com Thu Jun 18 12:34:33 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 18 Jun 2009 10:34:33 -0700 Subject: [llvm-commits] [llvm] r73579 - in /llvm/trunk: Makefile.rules docs/MakefileGuide.html tools/llvmc/driver/Makefile In-Reply-To: <4A39E715.6090008@lip6.fr> References: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> <1245246876.6797.19.camel@vostro-1510.invia> <0936EF7D-A706-4333-9D26-DAD9EB35D1ED@apple.com> <4A39E715.6090008@lip6.fr> Message-ID: On Jun 18, 2009, at 12:04 AM, Nicolas Geoffray wrote: > > Chris Lattner wrote: >> >> The big part of the change was to change .o -> .a. If nothing >> references the .o file within the .a, it is quite possible that the >> code in the .a isn't being linked in... I'm sorry for the breakage, >> if you have any idea what the right fix is, I'd really appreciate >> help :) >> > > So there are lots of functions in vmkit that are not used in vmkit's > source code, but that will be used at runtime. With the .o -> .a > change, > these functions get indeed removed from the final executable, which > makes vmkit crash because it can't find the functions. I see two > options > here: > > a) Generate a .o again. Have you left in Makefile.rules a way to > generate .o instead of .a? > b) Hack the source code to force these functions to be linked. I know > llvm is doing that a lot in its header files, but I don't know what is > the general rule for doing that. Do you have any advices? Hi Nicolas, We don't have makefile machinery to produce relinked .o's anymore, but we do have machinery to produce dynamic libraries (.so or .dylib). This should work for you. Alternatively, you can link with the - all_load option to the linker, which pulls in all object files in an archive. -Chris From kremenek at apple.com Thu Jun 18 12:47:18 2009 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 18 Jun 2009 17:47:18 -0000 Subject: [llvm-commits] [llvm] r73708 - in /llvm/trunk/lib: Support/CMakeLists.txt System/CMakeLists.txt Message-ID: <200906181747.n5IHlKkp006904@zion.cs.uiuc.edu> Author: kremenek Date: Thu Jun 18 12:47:09 2009 New Revision: 73708 URL: http://llvm.org/viewvc/llvm-project?rev=73708&view=rev Log: Update CMake files to account for new location of Threading.cpp. Modified: llvm/trunk/lib/Support/CMakeLists.txt llvm/trunk/lib/System/CMakeLists.txt Modified: llvm/trunk/lib/Support/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=73708&r1=73707&r2=73708&view=diff ============================================================================== --- llvm/trunk/lib/Support/CMakeLists.txt (original) +++ llvm/trunk/lib/Support/CMakeLists.txt Thu Jun 18 12:47:09 2009 @@ -25,7 +25,6 @@ StringMap.cpp StringPool.cpp SystemUtils.cpp - Threading.cpp Timer.cpp Triple.cpp raw_ostream.cpp Modified: llvm/trunk/lib/System/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/CMakeLists.txt?rev=73708&r1=73707&r2=73708&view=diff ============================================================================== --- llvm/trunk/lib/System/CMakeLists.txt (original) +++ llvm/trunk/lib/System/CMakeLists.txt Thu Jun 18 12:47:09 2009 @@ -12,6 +12,7 @@ Program.cpp RWMutex.cpp Signals.cpp + Threading.cpp TimeValue.cpp ) From resistor at mac.com Thu Jun 18 12:53:17 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 17:53:17 -0000 Subject: [llvm-commits] [llvm] r73709 - in /llvm/trunk: include/llvm/System/Mutex.h lib/System/Mutex.cpp lib/System/Unix/Mutex.inc lib/System/Win32/Mutex.inc Message-ID: <200906181753.n5IHrIBi007295@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 12:53:17 2009 New Revision: 73709 URL: http://llvm.org/viewvc/llvm-project?rev=73709&view=rev Log: Insert a SmartMutex templated class into the class hierarchy, which takes a template parameter specifying whether this mutex should become a no-op when not running in multithreaded mode. Make sys::Mutex a typedef of SmartMutex, to preserve source compatibility. Modified: llvm/trunk/include/llvm/System/Mutex.h llvm/trunk/lib/System/Mutex.cpp llvm/trunk/lib/System/Unix/Mutex.inc llvm/trunk/lib/System/Win32/Mutex.inc Modified: llvm/trunk/include/llvm/System/Mutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Mutex.h?rev=73709&r1=73708&r2=73709&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Mutex.h (original) +++ llvm/trunk/include/llvm/System/Mutex.h Thu Jun 18 12:53:17 2009 @@ -14,12 +14,14 @@ #ifndef LLVM_SYSTEM_MUTEX_H #define LLVM_SYSTEM_MUTEX_H +#include "llvm/System/Threading.h" + namespace llvm { namespace sys { /// @brief Platform agnostic Mutex class. - class Mutex + class MutexImpl { /// @name Constructors /// @{ @@ -30,11 +32,11 @@ /// also more likely to deadlock (same thread can't acquire more than /// once). /// @brief Default Constructor. - explicit Mutex(bool recursive = true); + explicit MutexImpl(bool recursive = true); /// Releases and removes the lock /// @brief Destructor - ~Mutex(); + ~MutexImpl(); /// @} /// @name Methods @@ -74,10 +76,46 @@ /// @name Do Not Implement /// @{ private: - Mutex(const Mutex & original); - void operator=(const Mutex &); + MutexImpl(const MutexImpl & original); + void operator=(const MutexImpl &); /// @} }; + + + /// SmartMutex - A mutex with a compile time constant parameter that + /// indicates whether this mutex should become a no-op when we're not + /// running in multithreaded mode. + template + class SmartMutex { + MutexImpl mtx; + public: + explicit SmartMutex(bool recursive = true) : mtx(recursive) { } + + bool acquire() { + if (!mt_only || (mt_only && llvm_is_multithreaded())) + return mtx.acquire(); + return true; + } + + bool release() { + if (!mt_only || (mt_only && llvm_is_multithreaded())) + return mtx.release(); + return true; + } + + bool tryacquire() { + if (!mt_only || (mt_only && llvm_is_multithreaded())) + return mtx.tryacquire(); + return true; + } + + private: + SmartMutex(const SmartMutex & original); + void operator=(const SmartMutex &); + }; + + /// Mutex - A standard, always enforced mutex. + typedef SmartMutex Mutex; } } Modified: llvm/trunk/lib/System/Mutex.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Mutex.cpp?rev=73709&r1=73708&r2=73709&view=diff ============================================================================== --- llvm/trunk/lib/System/Mutex.cpp (original) +++ llvm/trunk/lib/System/Mutex.cpp Thu Jun 18 12:53:17 2009 @@ -23,11 +23,11 @@ // Define all methods as no-ops if threading is explicitly disabled namespace llvm { using namespace sys; -Mutex::Mutex( bool recursive) { } -Mutex::~Mutex() { } -bool Mutex::acquire() { return true; } -bool Mutex::release() { return true; } -bool Mutex::tryacquire() { return true; } +MutexImpl::MutexImpl( bool recursive) { } +MutexImpl::~MutexImpl() { } +bool MutexImpl::acquire() { return true; } +bool MutexImpl::release() { return true; } +bool MutexImpl::tryacquire() { return true; } } #else @@ -55,7 +55,7 @@ static const bool pthread_enabled = true; // Construct a Mutex using pthread calls -Mutex::Mutex( bool recursive) +MutexImpl::MutexImpl( bool recursive) : data_(0) { if (pthread_enabled) @@ -94,7 +94,7 @@ } // Destruct a Mutex -Mutex::~Mutex() +MutexImpl::~MutexImpl() { if (pthread_enabled) { @@ -106,7 +106,7 @@ } bool -Mutex::acquire() +MutexImpl::acquire() { if (pthread_enabled) { @@ -120,7 +120,7 @@ } bool -Mutex::release() +MutexImpl::release() { if (pthread_enabled) { @@ -134,7 +134,7 @@ } bool -Mutex::tryacquire() +MutexImpl::tryacquire() { if (pthread_enabled) { Modified: llvm/trunk/lib/System/Unix/Mutex.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Mutex.inc?rev=73709&r1=73708&r2=73709&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Mutex.inc (original) +++ llvm/trunk/lib/System/Unix/Mutex.inc Thu Jun 18 12:53:17 2009 @@ -20,28 +20,28 @@ { using namespace sys; -Mutex::Mutex( bool recursive) +MutexImpl::MutexImpl( bool recursive) { } -Mutex::~Mutex() +MutexImpl::~MutexImpl() { } bool -Mutex::acquire() +MutexImpl::MutexImpl() { return true; } bool -Mutex::release() +MutexImpl::release() { return true; } bool -Mutex::tryacquire( void ) +MutexImpl::tryacquire( void ) { return true; } Modified: llvm/trunk/lib/System/Win32/Mutex.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Mutex.inc?rev=73709&r1=73708&r2=73709&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/Mutex.inc (original) +++ llvm/trunk/lib/System/Win32/Mutex.inc Thu Jun 18 12:53:17 2009 @@ -22,13 +22,13 @@ namespace llvm { using namespace sys; -Mutex::Mutex(bool /*recursive*/) +MutexImpl::MutexImpl(bool /*recursive*/) { data_ = new CRITICAL_SECTION; InitializeCriticalSection((LPCRITICAL_SECTION)data_); } -Mutex::~Mutex() +MutexImpl::~MutexImpl() { DeleteCriticalSection((LPCRITICAL_SECTION)data_); delete (LPCRITICAL_SECTION)data_; @@ -36,21 +36,21 @@ } bool -Mutex::acquire() +MutexImpl::acquire() { EnterCriticalSection((LPCRITICAL_SECTION)data_); return true; } bool -Mutex::release() +MutexImpl::release() { LeaveCriticalSection((LPCRITICAL_SECTION)data_); return true; } bool -Mutex::tryacquire() +MutexImpl::tryacquire() { return TryEnterCriticalSection((LPCRITICAL_SECTION)data_); } From gohman at apple.com Thu Jun 18 13:09:50 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Jun 2009 11:09:50 -0700 Subject: [llvm-commits] [llvm] r73401 - /llvm/trunk/lib/Analysis/IVUsers.cpp In-Reply-To: <4A39F352.9090003@microchip.com> References: <200906151838.n5FIcxns002287@zion.cs.uiuc.edu> <4A39F352.9090003@microchip.com> Message-ID: On Jun 18, 2009, at 12:57 AM, Sanjiv Gupta wrote: > Dan Gohman wrote: > >> Author: djg >> >> Date: Mon Jun 15 13:38:59 2009 >> >> New Revision: 73401 >> >> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=73401&view=rev >> >> Log: >> >> Code cleanups. getSCEVAtScope no longer uses SCEVCouldNotCompute. >> >> >> >> Modified: >> >> llvm/trunk/lib/Analysis/IVUsers.cpp >> >> >> >> Modified: llvm/trunk/lib/Analysis/IVUsers.cpp >> >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IVUsers.cpp?rev=73401&r1=73400&r2=73401&view=diff >> >> >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> >> --- llvm/trunk/lib/Analysis/IVUsers.cpp (original) >> >> +++ llvm/trunk/lib/Analysis/IVUsers.cpp Mon Jun 15 13:38:59 2009 >> >> @@ -120,9 +120,9 @@ >> >> // Use getSCEVAtScope to attempt to simplify other loops out of >> >> // the picture. >> >> SCEVHandle AddRecStart = AddRec->getStart(); >> >> - SCEVHandle BetterAddRecStart = SE->getSCEVAtScope(AddRecStart, >> UseLoop); >> >> - if (!isa(BetterAddRecStart)) >> >> - AddRecStart = BetterAddRecStart; >> >> + AddRecStart = SE->getSCEVAtScope(AddRecStart, UseLoop); >> >> + SCEVHandle AddRecStride = AddRec->getStepRecurrence(*SE); >> >> + AddRecStride = SE->getSCEVAtScope(AddRecStride, UseLoop); >> >> >> > Dan, > > Since you meant only code cleanup, the last line I think is left > there by mistake as in the original code we had only one call to > > SE->getSCEVAtScope(AddRecStart, UseLoop); which is already there two > lines above. Hmm, you're right that this wasn't pure cleanup. This commit is a change I had split out from a larger patch, and I missed that detail. The call isn't redundant though; the first call is doing getSCEVAtScope for the Start expression, and the second is doing it for the Stride expression. This probably isn't especially valuable at the moment, but it shouldn't cause trouble. Dan From dalej at apple.com Thu Jun 18 13:23:17 2009 From: dalej at apple.com (Dale Johannesen) Date: Thu, 18 Jun 2009 11:23:17 -0700 Subject: [llvm-commits] [llvm] r73579 - in /llvm/trunk: Makefile.rules docs/MakefileGuide.html tools/llvmc/driver/Makefile In-Reply-To: <4A39E715.6090008@lip6.fr> References: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> <1245246876.6797.19.camel@vostro-1510.invia> <0936EF7D-A706-4333-9D26-DAD9EB35D1ED@apple.com> <4A39E715.6090008@lip6.fr> Message-ID: <1E35726B-5D81-423D-9B34-6E181C5E5CBD@apple.com> On Jun 18, 2009, at 12:04 AMPDT, Nicolas Geoffray wrote: > Hi Chris, > > Chris Lattner wrote: >> >> The big part of the change was to change .o -> .a. If nothing >> references the .o file within the .a, it is quite possible that the >> code in the .a isn't being linked in... I'm sorry for the breakage, >> if you have any idea what the right fix is, I'd really appreciate >> help :) >> > > So there are lots of functions in vmkit that are not used in vmkit's > source code, but that will be used at runtime. With the .o -> .a > change, > these functions get indeed removed from the final executable, which > makes vmkit crash because it can't find the functions. I see two > options > here: > > a) Generate a .o again. Have you left in Makefile.rules a way to > generate .o instead of .a? > b) Hack the source code to force these functions to be linked. I know > llvm is doing that a lot in its header files, but I don't know what is > the general rule for doing that. Do you have any advices? __attribute__((used)) should do it. From resistor at mac.com Thu Jun 18 13:26:19 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 18:26:19 -0000 Subject: [llvm-commits] [llvm] r73710 - in /llvm/trunk: include/llvm/System/RWMutex.h lib/System/RWMutex.cpp lib/System/Unix/RWMutex.inc lib/System/Win32/RWMutex.inc Message-ID: <200906181826.n5IIQJVD009600@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 13:26:15 2009 New Revision: 73710 URL: http://llvm.org/viewvc/llvm-project?rev=73710&view=rev Log: Give RWMutex the SmartRWMutex treatment too. Modified: llvm/trunk/include/llvm/System/RWMutex.h llvm/trunk/lib/System/RWMutex.cpp llvm/trunk/lib/System/Unix/RWMutex.inc llvm/trunk/lib/System/Win32/RWMutex.inc Modified: llvm/trunk/include/llvm/System/RWMutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/RWMutex.h?rev=73710&r1=73709&r2=73710&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/RWMutex.h (original) +++ llvm/trunk/include/llvm/System/RWMutex.h Thu Jun 18 13:26:15 2009 @@ -14,12 +14,14 @@ #ifndef LLVM_SYSTEM_RWMUTEX_H #define LLVM_SYSTEM_RWMUTEX_H +#include "llvm/System/Threading.h" + namespace llvm { namespace sys { - /// @brief Platform agnostic Mutex class. - class RWMutex + /// @brief Platform agnostic RWMutex class. + class RWMutexImpl { /// @name Constructors /// @{ @@ -27,11 +29,11 @@ /// Initializes the lock but doesn't acquire it. /// @brief Default Constructor. - explicit RWMutex(); + explicit RWMutexImpl(); /// Releases and removes the lock /// @brief Destructor - ~RWMutex(); + ~RWMutexImpl(); /// @} /// @name Methods @@ -74,38 +76,80 @@ /// @name Do Not Implement /// @{ private: - RWMutex(const RWMutex & original); - void operator=(const RWMutex &); + RWMutexImpl(const RWMutexImpl & original); + void operator=(const RWMutexImpl &); /// @} }; + /// SmartMutex - An R/W mutex with a compile time constant parameter that + /// indicates whether this mutex should become a no-op when we're not + /// running in multithreaded mode. + template + class SmartRWMutex : RWMutexImpl { + public: + explicit SmartRWMutex() : RWMutexImpl() { } + + bool reader_acquire() { + if (!mt_only && llvm_is_multithreaded()) + return RWMutexImpl::reader_acquire(); + return true; + } + + bool reader_release() { + if (!mt_only || llvm_is_multithreaded()) + return RWMutexImpl::reader_release(); + return true; + } + + bool writer_acquire() { + if (!mt_only || llvm_is_multithreaded()) + return RWMutexImpl::writer_acquire(); + return true; + } + + bool writer_release() { + if (!mt_only || llvm_is_multithreaded()) + return RWMutexImpl::writer_release(); + return true; + } + + private: + SmartRWMutex(const SmartRWMutex & original); + void operator=(const SmartRWMutex &); + }; + typedef SmartRWMutex RWMutex; + /// ScopedReader - RAII acquisition of a reader lock - struct ScopedReader { - RWMutex* mutex; + template + struct SmartScopedReader { + SmartRWMutex* mutex; - explicit ScopedReader(RWMutex* m) { + explicit SmartScopedReader(SmartRWMutex* m) { mutex = m; mutex->reader_acquire(); } - ~ScopedReader() { + ~SmartScopedReader() { mutex->reader_release(); } }; + typedef SmartScopedReader ScopedReader; /// ScopedWriter - RAII acquisition of a writer lock - struct ScopedWriter { - RWMutex* mutex; + template + struct SmartScopedWriter { + SmartRWMutex* mutex; - explicit ScopedWriter(RWMutex* m) { + explicit SmartScopedWriter(SmartRWMutex* m) { mutex = m; mutex->writer_acquire(); } - ~ScopedWriter() { + ~SmartScopedWriter() { mutex->writer_release(); } }; + typedef SmartScopedWriter ScopedWriter; } } Modified: llvm/trunk/lib/System/RWMutex.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/RWMutex.cpp?rev=73710&r1=73709&r2=73710&view=diff ============================================================================== --- llvm/trunk/lib/System/RWMutex.cpp (original) +++ llvm/trunk/lib/System/RWMutex.cpp Thu Jun 18 13:26:15 2009 @@ -23,12 +23,12 @@ // Define all methods as no-ops if threading is explicitly disabled namespace llvm { using namespace sys; -RWMutex::RWMutex() { } -RWMutex::~RWMutex() { } -bool RWMutex::reader_acquire() { return true; } -bool RWMutex::reader_release() { return true; } -bool RWMutex::writer_acquire() { return true; } -bool RWMutex::writer_release() { return true; } +RWMutexImpl::RWMutexImpl() { } +RWMutexImpl::~RWMutexImpl() { } +bool RWMutexImpl::reader_acquire() { return true; } +bool RWMutexImpl::reader_release() { return true; } +bool RWMutexImpl::writer_acquire() { return true; } +bool RWMutexImpl::writer_release() { return true; } } #else @@ -56,7 +56,7 @@ static const bool pthread_enabled = true; // Construct a RWMutex using pthread calls -RWMutex::RWMutex() +RWMutexImpl::RWMutexImpl() : data_(0) { if (pthread_enabled) @@ -89,7 +89,7 @@ } // Destruct a RWMutex -RWMutex::~RWMutex() +RWMutexImpl::~RWMutexImpl() { if (pthread_enabled) { @@ -101,7 +101,7 @@ } bool -RWMutex::reader_acquire() +RWMutexImpl::reader_acquire() { if (pthread_enabled) { @@ -115,7 +115,7 @@ } bool -RWMutex::reader_release() +RWMutexImpl::reader_release() { if (pthread_enabled) { @@ -129,7 +129,7 @@ } bool -RWMutex::writer_acquire() +RWMutexImpl::writer_acquire() { if (pthread_enabled) { @@ -143,7 +143,7 @@ } bool -RWMutex::writer_release() +RWMutexImpl::writer_release() { if (pthread_enabled) { Modified: llvm/trunk/lib/System/Unix/RWMutex.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/RWMutex.inc?rev=73710&r1=73709&r2=73710&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/RWMutex.inc (original) +++ llvm/trunk/lib/System/Unix/RWMutex.inc Thu Jun 18 13:26:15 2009 @@ -20,23 +20,23 @@ using namespace sys; -RWMutex::RWMutex() { } +RWMutexImpl::RWMutexImpl() { } -RWMutex::~RWMutex() { } +RWMutexImpl::~RWMutexImpl() { } -bool RWMutex::reader_acquire() { +bool RWMutexImpl::reader_acquire() { return true; } -bool RWMutex::reader_release() { +bool RWMutexImpl::reader_release() { return true; } -bool RWMutex::writer_acquire() { +bool RWMutexImpl::writer_acquire() { return true; } -bool RWMutex::writer_release() { +bool RWMutexImpl::writer_release() { return true; } Modified: llvm/trunk/lib/System/Win32/RWMutex.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/RWMutex.inc?rev=73710&r1=73709&r2=73710&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/RWMutex.inc (original) +++ llvm/trunk/lib/System/Win32/RWMutex.inc Thu Jun 18 13:26:15 2009 @@ -24,32 +24,32 @@ namespace llvm { using namespace sys; -RWMutex::RWMutex() { +RWMutexImpl::RWMutexImpl() { data_ = calloc(1, sizeof(CRITICAL_SECTION)); InitializeCriticalSection(static_cast(data_)); } -RWMutex::~RWMutex() { +RWMutexImpl::~RWMutexImpl() { DeleteCriticalSection(static_cast(data_)); free(data_); } -bool RWMutex::reader_acquire() { +bool RWMutexImpl::reader_acquire() { EnterCriticalSection(static_cast(data_)); return true; } -bool RWMutex::reader_release() { +bool RWMutexImpl::reader_release() { LeaveCriticalSection(static_cast(data_)); return true; } -bool RWMutex::writer_acquire() { +bool RWMutexImpl::writer_acquire() { EnterCriticalSection(static_cast(data_)); return true; } -bool RWMutex::writer_release() { +bool RWMutexImpl::writer_release() { LeaveCriticalSection(static_cast(data_)); return true; } From resistor at mac.com Thu Jun 18 13:29:04 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 18:29:04 -0000 Subject: [llvm-commits] [llvm] r73711 - /llvm/trunk/include/llvm/System/Mutex.h Message-ID: <200906181829.n5IIT4Bx009771@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 13:29:03 2009 New Revision: 73711 URL: http://llvm.org/viewvc/llvm-project?rev=73711&view=rev Log: Simplify the SmartMutex implementation a bit. Modified: llvm/trunk/include/llvm/System/Mutex.h Modified: llvm/trunk/include/llvm/System/Mutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Mutex.h?rev=73711&r1=73710&r2=73711&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Mutex.h (original) +++ llvm/trunk/include/llvm/System/Mutex.h Thu Jun 18 13:29:03 2009 @@ -86,31 +86,30 @@ /// indicates whether this mutex should become a no-op when we're not /// running in multithreaded mode. template - class SmartMutex { - MutexImpl mtx; + class SmartMutex : public MutexImpl { public: - explicit SmartMutex(bool recursive = true) : mtx(recursive) { } + explicit SmartMutex(bool recursive = true) : MutexImpl(recursive) { } bool acquire() { - if (!mt_only || (mt_only && llvm_is_multithreaded())) - return mtx.acquire(); + if (!mt_only && llvm_is_multithreaded()) + return MutexImpl::acquire(); return true; } bool release() { - if (!mt_only || (mt_only && llvm_is_multithreaded())) - return mtx.release(); + if (!mt_only || llvm_is_multithreaded()) + return MutexImpl::release(); return true; } bool tryacquire() { - if (!mt_only || (mt_only && llvm_is_multithreaded())) - return mtx.tryacquire(); + if (!mt_only || llvm_is_multithreaded()) + return MutexImpl::tryacquire(); return true; } private: - SmartMutex(const SmartMutex & original); + SmartMutex(const SmartMutex & original); void operator=(const SmartMutex &); }; From clattner at apple.com Thu Jun 18 13:36:50 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 18 Jun 2009 11:36:50 -0700 Subject: [llvm-commits] [llvm] r73579 - in /llvm/trunk: Makefile.rules docs/MakefileGuide.html tools/llvmc/driver/Makefile In-Reply-To: <1E35726B-5D81-423D-9B34-6E181C5E5CBD@apple.com> References: <200906162300.n5GN0ga2012682@zion.cs.uiuc.edu> <1245246876.6797.19.camel@vostro-1510.invia> <0936EF7D-A706-4333-9D26-DAD9EB35D1ED@apple.com> <4A39E715.6090008@lip6.fr> <1E35726B-5D81-423D-9B34-6E181C5E5CBD@apple.com> Message-ID: <66A74C4B-B82F-4413-9C8B-E999B437E151@apple.com> On Jun 18, 2009, at 11:23 AM, Dale Johannesen wrote: >> So there are lots of functions in vmkit that are not used in vmkit's >> source code, but that will be used at runtime. With the .o -> .a >> change, >> these functions get indeed removed from the final executable, which >> makes vmkit crash because it can't find the functions. I see two >> options >> here: >> >> a) Generate a .o again. Have you left in Makefile.rules a way to >> generate .o instead of .a? >> b) Hack the source code to force these functions to be linked. I know >> llvm is doing that a lot in its header files, but I don't know what >> is >> the general rule for doing that. Do you have any advices? > > __attribute__((used)) should do it. __attribute__((used)) won't work with .a files. -Chris From resistor at mac.com Thu Jun 18 13:36:48 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 18:36:48 -0000 Subject: [llvm-commits] [llvm] r73712 - /llvm/trunk/lib/VMCore/Type.cpp Message-ID: <200906181836.n5IIaoGW009995@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 13:36:34 2009 New Revision: 73712 URL: http://llvm.org/viewvc/llvm-project?rev=73712&view=rev Log: Use SmartMutex to simplify. Modified: llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73712&r1=73711&r2=73712&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Thu Jun 18 13:36:34 2009 @@ -47,7 +47,9 @@ static ManagedStatic TypeMapLock; // Recursive lock used for guarding access to AbstractTypeUsers. -static ManagedStatic AbstractTypeUsersLock; +// NOTE: The false template parameter means this will no-op when we're not in +// multithreaded mode. +static ManagedStatic > AbstractTypeUsersLock; // Concrete/Abstract TypeDescriptions - We lazily calculate type descriptions // for types as they are needed. Because resolution of types must invalidate @@ -1469,13 +1471,9 @@ // it. This function is called primarily by the PATypeHandle class. void Type::addAbstractTypeUser(AbstractTypeUser *U) const { assert(isAbstract() && "addAbstractTypeUser: Current type not abstract!"); - if (llvm_is_multithreaded()) { - AbstractTypeUsersLock->acquire(); - AbstractTypeUsers.push_back(U); - AbstractTypeUsersLock->release(); - } else { - AbstractTypeUsers.push_back(U); - } + AbstractTypeUsersLock->acquire(); + AbstractTypeUsers.push_back(U); + AbstractTypeUsersLock->release(); } @@ -1485,7 +1483,7 @@ // is annihilated, because there is no way to get a reference to it ever again. // void Type::removeAbstractTypeUser(AbstractTypeUser *U) const { - if (llvm_is_multithreaded()) AbstractTypeUsersLock->acquire(); + AbstractTypeUsersLock->acquire(); // Search from back to front because we will notify users from back to // front. Also, it is likely that there will be a stack like behavior to @@ -1514,7 +1512,7 @@ this->destroy(); } - if (llvm_is_multithreaded()) AbstractTypeUsersLock->release(); + AbstractTypeUsersLock->release(); } // unlockedRefineAbstractTypeTo - This function is used when it is discovered @@ -1565,7 +1563,7 @@ // will not cause users to drop off of the use list. If we resolve to ourself // we succeed! // - if (llvm_is_multithreaded()) AbstractTypeUsersLock->acquire(); + AbstractTypeUsersLock->acquire(); while (!AbstractTypeUsers.empty() && NewTy != this) { AbstractTypeUser *User = AbstractTypeUsers.back(); @@ -1581,7 +1579,7 @@ assert(AbstractTypeUsers.size() != OldSize && "AbsTyUser did not remove self from user list!"); } - if (llvm_is_multithreaded()) AbstractTypeUsersLock->release(); + AbstractTypeUsersLock->release(); // If we were successful removing all users from the type, 'this' will be // deleted when the last PATypeHolder is destroyed or updated from this type. @@ -1612,7 +1610,7 @@ DOUT << "typeIsREFINED type: " << (void*)this << " " << *this << "\n"; #endif - if (llvm_is_multithreaded()) AbstractTypeUsersLock->acquire(); + AbstractTypeUsersLock->acquire(); unsigned OldSize = AbstractTypeUsers.size(); OldSize=OldSize; while (!AbstractTypeUsers.empty()) { AbstractTypeUser *ATU = AbstractTypeUsers.back(); @@ -1621,7 +1619,7 @@ assert(AbstractTypeUsers.size() < OldSize-- && "AbstractTypeUser did not remove itself from the use list!"); } - if (llvm_is_multithreaded()) AbstractTypeUsersLock->release(); + AbstractTypeUsersLock->release(); } // refineAbstractType - Called when a contained type is found to be more From clattner at apple.com Thu Jun 18 13:38:44 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 18 Jun 2009 11:38:44 -0700 Subject: [llvm-commits] Cyclic dependencies between LLVM libraries with debug builds In-Reply-To: <4A3A14AA.4020105@free.fr> References: <4A3A14AA.4020105@free.fr> Message-ID: On Jun 18, 2009, at 3:19 AM, Duncan Sands wrote: > If I configure without any options (equivalent to --disable-optimized > --enable-assertions) on x64-64 linux then the build fails with: > > llvm[1]: Checking for cyclic dependencies between LLVM libraries. > find-cycles.pl: Circular dependency between *.a files: > find-cycles.pl: libLLVMSparcAsmPrinter.a libLLVMSparcCodeGen.a > find-cycles.pl: Circular dependency between *.a files: > find-cycles.pl: libLLVMCellSPUAsmPrinter.a libLLVMCellSPUCodeGen.a > find-cycles.pl: Circular dependency between *.a files: > find-cycles.pl: libLLVMAlphaAsmPrinter.a libLLVMAlphaCodeGen.a > find-cycles.pl: Circular dependency between *.a files: > find-cycles.pl: libLLVMIA64AsmPrinter.a libLLVMIA64CodeGen.a > > Any ideas? I'm not seeing that. Can you go into tools/llvm-config and run an appropriately path-adjusted version of this: /usr/bin/perl /Users/sabre/llvm/utils/GenLibDeps.pl -flat -why /Users/ sabre/llvm/Debug/lib "/usr/bin/nm -p" > out.txt and send me out.txt? Thanks, -Chris From clattner at apple.com Thu Jun 18 13:40:46 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 18 Jun 2009 11:40:46 -0700 Subject: [llvm-commits] [llvm] r73646 - /llvm/trunk/include/llvm/Support/IRBuilder.h In-Reply-To: References: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> <2AC709DE-1579-427A-8D43-B0B0546791FE@apple.com> Message-ID: <47A0715A-B487-443D-BE88-D9F52DF7AB9E@apple.com> On Jun 18, 2009, at 1:10 AM, Anton Korobeynikov wrote: > Hi Chris > >> Anton, why isn't the caller and callee already getting the right >> calling conv? This seems like the wrong fix, > We have separate calling conv fields on, for example, Function and > CallInst. That's why API user should put correct calling conv on > CallInst during creation of such (see, for example, > SimplifyCFGPass.cpp:ChangeToCall). By default CI's are created with C > calling conv and in general we'll have calling conv mismatch between > caller and callee if API user won't tune the calling conv of CI. > > SimplifyLibCalls pass uses IRBuilder to insert calls to strlen & > friends. They can be already defined in the module with non-C calling > convention, thus we need to put the same calling conv on CI also. I > thought it's much safer to let IRBuilder to do this by default instead > of letting each user to do this explicitly. Also, since custom CCs are > not so frequent stuff, possible bugs due to CC mismatch might be > pretty tricky to catch of we'll delegate tweaking of CC to API user. I discussed this with Anton on IRC and convinced (I think!) him to revert the changes to IRBuilder. I'd like to keep it really obvious how the IRbuilder interfaces relate to the generated IR. One of my fears is that making this be "magic" will make enough stuff work in the obvious cases that we'll be left with obscure bugs in the uncommon cases. By making the client have to directly think about CC's, we avoid some bugs. -Chris From bob.wilson at apple.com Thu Jun 18 13:43:26 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 18 Jun 2009 11:43:26 -0700 Subject: [llvm-commits] [PATCH] Remove GNU particuliers from NewNightlyTest.pl , more system portable. In-Reply-To: References: Message-ID: Nice cleanup. Thanks, Benjamin. I'm going to try it out with my nightly tester. If everything goes well, I'll commit your patch tomorrow. On Jun 18, 2009, at 4:31 AM, Benjamin Kramer wrote: > Sorry, but seeing this ugly perl code almost made my cry (not your > fault though). So I decided to port it to File::Find which is part > of perl's standard library. > > This gives us some advantages: > 1. portability: File::Find works even on windows ;) > 2. performance: the new code is >100 times faster on my machine. The > slowdown is probably caused by backtracking in the old regex > 3. cleanup: there were lots of duplicated code > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From resistor at mac.com Thu Jun 18 14:10:21 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 19:10:21 -0000 Subject: [llvm-commits] [llvm] r73714 - /llvm/trunk/lib/VMCore/Constants.cpp Message-ID: <200906181910.n5IJAMeJ011216@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 14:10:19 2009 New Revision: 73714 URL: http://llvm.org/viewvc/llvm-project?rev=73714&view=rev Log: Simplify a lot of code by using a R/W mutex that becomes a no-op when multithreading is disabled. Modified: llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73714&r1=73713&r2=73714&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Thu Jun 18 14:10:19 2009 @@ -37,7 +37,8 @@ // Constant Class //===----------------------------------------------------------------------===// -ManagedStatic ConstantsLock; +// Becomes a no-op when multithreading is disabled. +ManagedStatic > ConstantsLock; void Constant::destroyConstantImpl() { // When a Constant is destroyed, there may be lingering @@ -300,27 +301,20 @@ // get an existing value or the insertion position DenseMapAPIntKeyInfo::KeyTy Key(V, ITy); - if (llvm_is_multithreaded()) { - ConstantsLock->reader_acquire(); - ConstantInt *&Slot = (*IntConstants)[Key]; - ConstantsLock->reader_release(); - + ConstantsLock->reader_acquire(); + ConstantInt *&Slot = (*IntConstants)[Key]; + ConstantsLock->reader_release(); + + if (!Slot) { + sys::SmartScopedWriter Writer(&*ConstantsLock); + ConstantInt *&NewSlot = (*IntConstants)[Key]; if (!Slot) { - sys::ScopedWriter Writer(&*ConstantsLock); - ConstantInt *&Slot = (*IntConstants)[Key]; - if (!Slot) { - Slot = new ConstantInt(ITy, V); - } + NewSlot = new ConstantInt(ITy, V); } - return Slot; + return NewSlot; } else { - ConstantInt *&Slot = (*IntConstants)[Key]; - // if it exists, return it. - if (Slot) - return Slot; - // otherwise create a new one, insert it, and return it. - return Slot = new ConstantInt(ITy, V); + return Slot; } } @@ -414,56 +408,35 @@ ConstantFP *ConstantFP::get(const APFloat &V) { DenseMapAPFloatKeyInfo::KeyTy Key(V); - if (llvm_is_multithreaded()) { - ConstantsLock->reader_acquire(); - ConstantFP *&Slot = (*FPConstants)[Key]; - ConstantsLock->reader_release(); - - if (!Slot) { - sys::ScopedWriter Writer(&*ConstantsLock); - Slot = (*FPConstants)[Key]; - if (!Slot) { - const Type *Ty; - if (&V.getSemantics() == &APFloat::IEEEsingle) - Ty = Type::FloatTy; - else if (&V.getSemantics() == &APFloat::IEEEdouble) - Ty = Type::DoubleTy; - else if (&V.getSemantics() == &APFloat::x87DoubleExtended) - Ty = Type::X86_FP80Ty; - else if (&V.getSemantics() == &APFloat::IEEEquad) - Ty = Type::FP128Ty; - else { - assert(&V.getSemantics() == &APFloat::PPCDoubleDouble && - "Unknown FP format"); - Ty = Type::PPC_FP128Ty; - } - - Slot = new ConstantFP(Ty, V); + ConstantsLock->reader_acquire(); + ConstantFP *&Slot = (*FPConstants)[Key]; + ConstantsLock->reader_release(); + + if (!Slot) { + sys::SmartScopedWriter Writer(&*ConstantsLock); + ConstantFP *&NewSlot = (*FPConstants)[Key]; + if (!NewSlot) { + const Type *Ty; + if (&V.getSemantics() == &APFloat::IEEEsingle) + Ty = Type::FloatTy; + else if (&V.getSemantics() == &APFloat::IEEEdouble) + Ty = Type::DoubleTy; + else if (&V.getSemantics() == &APFloat::x87DoubleExtended) + Ty = Type::X86_FP80Ty; + else if (&V.getSemantics() == &APFloat::IEEEquad) + Ty = Type::FP128Ty; + else { + assert(&V.getSemantics() == &APFloat::PPCDoubleDouble && + "Unknown FP format"); + Ty = Type::PPC_FP128Ty; } + NewSlot = new ConstantFP(Ty, V); } - return Slot; - } else { - ConstantFP *&Slot = (*FPConstants)[Key]; - if (Slot) return Slot; - - const Type *Ty; - if (&V.getSemantics() == &APFloat::IEEEsingle) - Ty = Type::FloatTy; - else if (&V.getSemantics() == &APFloat::IEEEdouble) - Ty = Type::DoubleTy; - else if (&V.getSemantics() == &APFloat::x87DoubleExtended) - Ty = Type::X86_FP80Ty; - else if (&V.getSemantics() == &APFloat::IEEEquad) - Ty = Type::FP128Ty; - else { - assert(&V.getSemantics() == &APFloat::PPCDoubleDouble && - "Unknown FP format"); - Ty = Type::PPC_FP128Ty; - } - - return Slot = new ConstantFP(Ty, V); + return NewSlot; } + + return Slot; } /// get() - This returns a constant fp for the specified value in the @@ -1255,42 +1228,32 @@ /// necessary. ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { MapKey Lookup(Ty, V); - if (llvm_is_multithreaded()) { - ConstantClass* Result = 0; + ConstantClass* Result = 0; + + ConstantsLock->reader_acquire(); + typename MapTy::iterator I = Map.find(Lookup); + // Is it in the map? + if (I != Map.end()) + Result = static_cast(I->second); + ConstantsLock->reader_release(); - ConstantsLock->reader_acquire(); - typename MapTy::iterator I = Map.find(Lookup); + if (!Result) { + sys::SmartScopedWriter Writer(&*ConstantsLock); + I = Map.find(Lookup); // Is it in the map? if (I != Map.end()) Result = static_cast(I->second); - ConstantsLock->reader_release(); - if (!Result) { - sys::ScopedWriter Writer(&*ConstantsLock); - I = Map.find(Lookup); - // Is it in the map? - if (I != Map.end()) - Result = static_cast(I->second); - if (!Result) { - // If no preexisting value, create one now... - Result = Create(Ty, V, I); - } + // If no preexisting value, create one now... + Result = Create(Ty, V, I); } - - return Result; - } else { - typename MapTy::iterator I = Map.find(Lookup); - // Is it in the map? - if (I != Map.end()) - return static_cast(I->second); - - // If no preexisting value, create one now... - return Create(Ty, V, I); } + + return Result; } void remove(ConstantClass *CP) { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + ConstantsLock->writer_acquire(); typename MapTy::iterator I = FindExistingElement(CP); assert(I != Map.end() && "Constant not found in constant table!"); assert(I->second == CP && "Didn't find correct element?"); @@ -1339,7 +1302,7 @@ Map.erase(I); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + ConstantsLock->writer_release(); } @@ -1377,7 +1340,7 @@ } void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) { - if (llvm_is_multithreaded()) ConstantsLock->writer_acquire(); + ConstantsLock->writer_acquire(); typename AbstractTypeMapTy::iterator I = AbstractTypeMap.find(cast(OldTy)); @@ -1396,17 +1359,14 @@ I = AbstractTypeMap.find(cast(OldTy)); } while (I != AbstractTypeMap.end()); - if (llvm_is_multithreaded()) ConstantsLock->writer_release(); + ConstantsLock->writer_release(); } // If the type became concrete without being refined to any other existing // type, we just remove ourselves from the ATU list. void typeBecameConcrete(const DerivedType *AbsTy) { - if (llvm_is_multithreaded()) { - sys::ScopedWriter Writer(&*ConstantsLock); - AbsTy->removeAbstractTypeUser(this); - } else - AbsTy->removeAbstractTypeUser(this); + sys::SmartScopedWriter Writer(&*ConstantsLock); + AbsTy->removeAbstractTypeUser(this); } void dump() const { @@ -1708,12 +1668,8 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantVector::destroyConstant() { - - if (llvm_is_multithreaded()) { - sys::ScopedWriter Write(&*ConstantsLock); - VectorConstants->remove(this); - } else - VectorConstants->remove(this); + sys::SmartScopedWriter Write(&*ConstantsLock); + VectorConstants->remove(this); destroyConstantImpl(); } @@ -1784,11 +1740,8 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantPointerNull::destroyConstant() { - if (llvm_is_multithreaded()) { - sys::ScopedWriter Writer(&*ConstantsLock); - NullPtrConstants->remove(this); - } else - NullPtrConstants->remove(this); + sys::SmartScopedWriter Writer(&*ConstantsLock); + NullPtrConstants->remove(this); destroyConstantImpl(); } @@ -1847,33 +1800,19 @@ static ManagedStatic > MDStringCache; MDString *MDString::get(const char *StrBegin, const char *StrEnd) { - if (llvm_is_multithreaded()) { - sys::ScopedWriter Writer(&*ConstantsLock); - StringMapEntry &Entry = MDStringCache->GetOrCreateValue( - StrBegin, StrEnd); - MDString *&S = Entry.getValue(); - if (!S) S = new MDString(Entry.getKeyData(), - Entry.getKeyData() + Entry.getKeyLength()); + sys::SmartScopedWriter Writer(&*ConstantsLock); + StringMapEntry &Entry = MDStringCache->GetOrCreateValue( + StrBegin, StrEnd); + MDString *&S = Entry.getValue(); + if (!S) S = new MDString(Entry.getKeyData(), + Entry.getKeyData() + Entry.getKeyLength()); - return S; - } else { - StringMapEntry &Entry = MDStringCache->GetOrCreateValue( - StrBegin, StrEnd); - MDString *&S = Entry.getValue(); - if (!S) S = new MDString(Entry.getKeyData(), - Entry.getKeyData() + Entry.getKeyLength()); - - return S; - } + return S; } void MDString::destroyConstant() { - if (llvm_is_multithreaded()) { - sys::ScopedWriter Writer(&*ConstantsLock); - MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd)); - } else - MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd)); - + sys::SmartScopedWriter Writer(&*ConstantsLock); + MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd)); destroyConstantImpl(); } @@ -1898,41 +1837,26 @@ for (unsigned i = 0; i != NumVals; ++i) ID.AddPointer(Vals[i]); - if (llvm_is_multithreaded()) { - ConstantsLock->reader_acquire(); - void *InsertPoint; - MDNode *N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); - ConstantsLock->reader_release(); - + ConstantsLock->reader_acquire(); + void *InsertPoint; + MDNode *N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); + ConstantsLock->reader_release(); + + if (!N) { + sys::SmartScopedWriter Writer(&*ConstantsLock); + N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); if (!N) { - sys::ScopedWriter Writer(&*ConstantsLock); - N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); - if (!N) { - // InsertPoint will have been set by the FindNodeOrInsertPos call. - MDNode *N = new(0) MDNode(Vals, NumVals); - MDNodeSet->InsertNode(N, InsertPoint); - } + // InsertPoint will have been set by the FindNodeOrInsertPos call. + N = new(0) MDNode(Vals, NumVals); + MDNodeSet->InsertNode(N, InsertPoint); } - - return N; - } else { - void *InsertPoint; - if (MDNode *N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint)) - return N; - - // InsertPoint will have been set by the FindNodeOrInsertPos call. - MDNode *N = new(0) MDNode(Vals, NumVals); - MDNodeSet->InsertNode(N, InsertPoint); - return N; } + return N; } void MDNode::destroyConstant() { - if (llvm_is_multithreaded()) { - sys::ScopedWriter Writer(&*ConstantsLock); - MDNodeSet->RemoveNode(this); - } else - MDNodeSet->RemoveNode(this); + sys::SmartScopedWriter Writer(&*ConstantsLock); + MDNodeSet->RemoveNode(this); destroyConstantImpl(); } @@ -2797,12 +2721,8 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantExpr::destroyConstant() { - if (llvm_is_multithreaded()) { - sys::ScopedWriter Writer(&*ConstantsLock); - ExprConstants->remove(this); - } else - ExprConstants->remove(this); - + sys::SmartScopedWriter Writer(&*ConstantsLock); + ExprConstants->remove(this); destroyConstantImpl(); } @@ -2866,7 +2786,7 @@ Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. - sys::ScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(&*ConstantsLock); bool Exists; ArrayConstantsTy::MapTy::iterator I = ArrayConstants->InsertOrGetItem(Lookup, Exists); @@ -2942,7 +2862,7 @@ Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. - sys::ScopedWriter Writer(&*ConstantsLock); + sys::SmartScopedWriter Writer(&*ConstantsLock); bool Exists; StructConstantsTy::MapTy::iterator I = StructConstants->InsertOrGetItem(Lookup, Exists); From eocallaghan at auroraux.org Thu Jun 18 14:28:11 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Thu, 18 Jun 2009 20:28:11 +0100 Subject: [llvm-commits] [PATCH] Remove GNU particuliers from NewNightlyTest.pl , more system portable. In-Reply-To: References: Message-ID: <521640720906181228u11fc6309o24d143bfcb980eba@mail.gmail.com> Thank you very much Benjamin. This was much needed. Regards, Edward. 2009/6/18 Bob Wilson : > Nice cleanup. ?Thanks, Benjamin. ?I'm going to try it out with my > nightly tester. ?If everything goes well, I'll commit your patch > tomorrow. > > On Jun 18, 2009, at 4:31 AM, Benjamin Kramer wrote: > >> Sorry, but seeing this ugly perl code almost made my cry (not your >> fault though). So I decided to port it to File::Find which is part >> of perl's standard library. >> >> This gives us some advantages: >> 1. portability: File::Find works even on windows ;) >> 2. performance: the new code is >100 times faster on my machine. The >> slowdown is probably caused by backtracking in the old regex >> 3. cleanup: there were lots of duplicated code >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- -- Edward O'Callaghan http://www.auroraux.org/ eocallaghan at auroraux dot org From asl at math.spbu.ru Thu Jun 18 15:05:41 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Thu, 18 Jun 2009 20:05:41 -0000 Subject: [llvm-commits] [llvm] r73715 - in /llvm/trunk: include/llvm/Support/IRBuilder.h lib/Transforms/Scalar/SimplifyLibCalls.cpp Message-ID: <200906182005.n5IK5hH1013298@zion.cs.uiuc.edu> Author: asl Date: Thu Jun 18 15:05:31 2009 New Revision: 73715 URL: http://llvm.org/viewvc/llvm-project?rev=73715&view=rev Log: Revert IRBuilder CC propagation. Fix SimplifyLibCalls instead. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=73715&r1=73714&r2=73715&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Thu Jun 18 15:05:31 2009 @@ -154,10 +154,8 @@ InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, InputIterator ArgBegin, InputIterator ArgEnd, const char *Name = "") { - return Insert(TransferAttributes(InvokeInst::Create(Callee, - NormalDest, UnwindDest, - ArgBegin, ArgEnd), - Callee), Name); + return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, + ArgBegin, ArgEnd), Name); } UnwindInst *CreateUnwind() { @@ -589,61 +587,32 @@ return Insert(PHINode::Create(Ty), Name); } - CallInst *TransferAttributes(CallInst *CI, const Value* Callee) const { - if (const GlobalAlias *GA = dyn_cast(Callee)) - Callee = GA->getAliasedGlobal(); - - if (const Function *F = dyn_cast(Callee)) { - CI->setCallingConv(F->getCallingConv()); - CI->setAttributes(F->getAttributes()); - } - - return CI; - } - - InvokeInst *TransferAttributes(InvokeInst *II, const Value* Callee) const { - if (const GlobalAlias *GA = dyn_cast(Callee)) - Callee = GA->getAliasedGlobal(); - - if (const Function *F = dyn_cast(Callee)) { - II->setCallingConv(F->getCallingConv()); - II->setAttributes(F->getAttributes()); - } - - return II; - } - CallInst *CreateCall(Value *Callee, const char *Name = "") { - return Insert(TransferAttributes(CallInst::Create(Callee), Callee), Name); + return Insert(CallInst::Create(Callee), Name); } CallInst *CreateCall(Value *Callee, Value *Arg, const char *Name = "") { - return Insert(TransferAttributes(CallInst::Create(Callee, Arg), - Callee), Name); + return Insert(CallInst::Create(Callee, Arg), Name); } CallInst *CreateCall2(Value *Callee, Value *Arg1, Value *Arg2, const char *Name = "") { Value *Args[] = { Arg1, Arg2 }; - return Insert(TransferAttributes(CallInst::Create(Callee, Args, Args+2), - Callee), Name); + return Insert(CallInst::Create(Callee, Args, Args+2), Name); } CallInst *CreateCall3(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, const char *Name = "") { Value *Args[] = { Arg1, Arg2, Arg3 }; - return Insert(TransferAttributes(CallInst::Create(Callee, Args, Args+3), - Callee), Name); + return Insert(CallInst::Create(Callee, Args, Args+3), Name); } CallInst *CreateCall4(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, Value *Arg4, const char *Name = "") { Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; - return Insert(TransferAttributes(CallInst::Create(Callee, Args, Args+4), - Callee), Name); + return Insert(CallInst::Create(Callee, Args, Args+4), Name); } template CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, InputIterator ArgEnd, const char *Name = "") { - return Insert(TransferAttributes(CallInst::Create(Callee, ArgBegin, ArgEnd), - Callee), Name); + return Insert(CallInst::Create(Callee, ArgBegin, ArgEnd), Name); } Value *CreateSelect(Value *C, Value *True, Value *False, Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=73715&r1=73714&r2=73715&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu Jun 18 15:05:31 2009 @@ -135,7 +135,11 @@ TD->getIntPtrType(), PointerType::getUnqual(Type::Int8Ty), NULL); - return B.CreateCall(StrLen, CastToCStr(Ptr, B), "strlen"); + CallInst *CI = B.CreateCall(StrLen, CastToCStr(Ptr, B), "strlen"); + if (const Function *F = dyn_cast(StrLen->stripPointerCasts())) + CI->setCallingConv(F->getCallingConv()); + + return CI; } /// EmitMemCpy - Emit a call to the memcpy function to the builder. This always @@ -164,7 +168,12 @@ PointerType::getUnqual(Type::Int8Ty), Type::Int32Ty, TD->getIntPtrType(), NULL); - return B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr"); + CallInst *CI = B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr"); + + if (const Function *F = dyn_cast(MemChr->stripPointerCasts())) + CI->setCallingConv(F->getCallingConv()); + + return CI; } /// EmitMemCmp - Emit a call to the memcmp function. @@ -182,8 +191,13 @@ PointerType::getUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty), TD->getIntPtrType(), NULL); - return B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B), - Len, "memcmp"); + CallInst *CI = B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B), + Len, "memcmp"); + + if (const Function *F = dyn_cast(MemCmp->stripPointerCasts())) + CI->setCallingConv(F->getCallingConv()); + + return CI; } /// EmitMemSet - Emit a call to the memset function @@ -217,20 +231,30 @@ NameBuffer[NameLen+1] = 0; Name = NameBuffer; } - + Module *M = Caller->getParent(); - Value *Callee = M->getOrInsertFunction(Name, Op->getType(), + Value *Callee = M->getOrInsertFunction(Name, Op->getType(), Op->getType(), NULL); - return B.CreateCall(Callee, Op, Name); + CallInst *CI = B.CreateCall(Callee, Op, Name); + + if (const Function *F = dyn_cast(Callee->stripPointerCasts())) + CI->setCallingConv(F->getCallingConv()); + + return CI; } /// EmitPutChar - Emit a call to the putchar function. This assumes that Char /// is an integer. void LibCallOptimization::EmitPutChar(Value *Char, IRBuilder<> &B) { Module *M = Caller->getParent(); - Value *F = M->getOrInsertFunction("putchar", Type::Int32Ty, - Type::Int32Ty, NULL); - B.CreateCall(F, B.CreateIntCast(Char, Type::Int32Ty, "chari"), "putchar"); + Value *PutChar = M->getOrInsertFunction("putchar", Type::Int32Ty, + Type::Int32Ty, NULL); + CallInst *CI = B.CreateCall(PutChar, + B.CreateIntCast(Char, Type::Int32Ty, "chari"), + "putchar"); + + if (const Function *F = dyn_cast(PutChar->stripPointerCasts())) + CI->setCallingConv(F->getCallingConv()); } /// EmitPutS - Emit a call to the puts function. This assumes that Str is @@ -241,10 +265,14 @@ AWI[0] = AttributeWithIndex::get(1, Attribute::NoCapture); AWI[1] = AttributeWithIndex::get(~0u, Attribute::NoUnwind); - Value *F = M->getOrInsertFunction("puts", AttrListPtr::get(AWI, 2), - Type::Int32Ty, - PointerType::getUnqual(Type::Int8Ty), NULL); - B.CreateCall(F, CastToCStr(Str, B), "puts"); + Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI, 2), + Type::Int32Ty, + PointerType::getUnqual(Type::Int8Ty), + NULL); + CallInst *CI = B.CreateCall(PutS, CastToCStr(Str, B), "puts"); + if (const Function *F = dyn_cast(PutS->stripPointerCasts())) + CI->setCallingConv(F->getCallingConv()); + } /// EmitFPutC - Emit a call to the fputc function. This assumes that Char is @@ -258,12 +286,14 @@ if (isa(File->getType())) F = M->getOrInsertFunction("fputc", AttrListPtr::get(AWI, 2), Type::Int32Ty, Type::Int32Ty, File->getType(), NULL); - else F = M->getOrInsertFunction("fputc", Type::Int32Ty, Type::Int32Ty, File->getType(), NULL); Char = B.CreateIntCast(Char, Type::Int32Ty, "chari"); - B.CreateCall2(F, Char, File, "fputc"); + CallInst *CI = B.CreateCall2(F, Char, File, "fputc"); + + if (const Function *Fn = dyn_cast(F->stripPointerCasts())) + CI->setCallingConv(Fn->getCallingConv()); } /// EmitFPutS - Emit a call to the puts function. Str is required to be a @@ -283,7 +313,10 @@ F = M->getOrInsertFunction("fputs", Type::Int32Ty, PointerType::getUnqual(Type::Int8Ty), File->getType(), NULL); - B.CreateCall2(F, CastToCStr(Str, B), File, "fputs"); + CallInst *CI = B.CreateCall2(F, CastToCStr(Str, B), File, "fputs"); + + if (const Function *Fn = dyn_cast(F->stripPointerCasts())) + CI->setCallingConv(Fn->getCallingConv()); } /// EmitFWrite - Emit a call to the fwrite function. This assumes that Ptr is @@ -307,8 +340,11 @@ PointerType::getUnqual(Type::Int8Ty), TD->getIntPtrType(), TD->getIntPtrType(), File->getType(), NULL); - B.CreateCall4(F, CastToCStr(Ptr, B), Size, - ConstantInt::get(TD->getIntPtrType(), 1), File); + CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size, + ConstantInt::get(TD->getIntPtrType(), 1), File); + + if (const Function *Fn = dyn_cast(F->stripPointerCasts())) + CI->setCallingConv(Fn->getCallingConv()); } //===----------------------------------------------------------------------===// @@ -1039,7 +1075,7 @@ if (OpC->getOperand(0)->getType()->getPrimitiveSizeInBits() < 32) LdExpArg = B.CreateZExt(OpC->getOperand(0), Type::Int32Ty, "tmp"); } - + if (LdExpArg) { const char *Name; if (Op->getType() == Type::FloatTy) @@ -1056,12 +1092,15 @@ Module *M = Caller->getParent(); Value *Callee = M->getOrInsertFunction(Name, Op->getType(), Op->getType(), Type::Int32Ty,NULL); - return B.CreateCall2(Callee, One, LdExpArg); + CallInst *CI = B.CreateCall2(Callee, One, LdExpArg); + if (const Function *F = dyn_cast(Callee->stripPointerCasts())) + CI->setCallingConv(F->getCallingConv()); + + return CI; } return 0; } }; - //===---------------------------------------===// // Double -> Float Shrinking Optimizations for Unary Functions like 'floor' @@ -1072,7 +1111,7 @@ if (FT->getNumParams() != 1 || FT->getReturnType() != Type::DoubleTy || FT->getParamType(0) != Type::DoubleTy) return 0; - + // If this is something like 'floor((double)floatval)', convert to floorf. FPExtInst *Cast = dyn_cast(CI->getOperand(1)); if (Cast == 0 || Cast->getOperand(0)->getType() != Type::FloatTy) From resistor at mac.com Thu Jun 18 15:15:43 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 20:15:43 -0000 Subject: [llvm-commits] [llvm] r73716 - /llvm/trunk/lib/VMCore/Type.cpp Message-ID: <200906182015.n5IKFksS013939@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 15:15:26 2009 New Revision: 73716 URL: http://llvm.org/viewvc/llvm-project?rev=73716&view=rev Log: Simplify using mutexes that become no-ops when not in multithreaded mode. Modified: llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73716&r1=73715&r2=73716&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Thu Jun 18 15:15:26 2009 @@ -44,7 +44,7 @@ //===----------------------------------------------------------------------===// // Reader/writer lock used for guarding access to the type maps. -static ManagedStatic TypeMapLock; +static ManagedStatic > TypeMapLock; // Recursive lock used for guarding access to AbstractTypeUsers. // NOTE: The false template parameter means this will no-op when we're not in @@ -1003,36 +1003,26 @@ IntegerValType IVT(NumBits); IntegerType *ITy = 0; - if (llvm_is_multithreaded()) { - // First, see if the type is already in the table, for which - // a reader lock suffices. - TypeMapLock->reader_acquire(); - ITy = IntegerTypes->get(IVT); - TypeMapLock->reader_release(); + + // First, see if the type is already in the table, for which + // a reader lock suffices. + TypeMapLock->reader_acquire(); + ITy = IntegerTypes->get(IVT); + TypeMapLock->reader_release(); - if (!ITy) { - // OK, not in the table, get a writer lock. - TypeMapLock->writer_acquire(); - ITy = IntegerTypes->get(IVT); - - // We need to _recheck_ the table in case someone - // put it in between when we released the reader lock - // and when we gained the writer lock! - if (!ITy) { - // Value not found. Derive a new type! - ITy = new IntegerType(NumBits); - IntegerTypes->add(IVT, ITy); - } + if (!ITy) { + // OK, not in the table, get a writer lock. + sys::SmartScopedWriter Writer(&*TypeMapLock); + ITy = IntegerTypes->get(IVT); - TypeMapLock->writer_release(); + // We need to _recheck_ the table in case someone + // put it in between when we released the reader lock + // and when we gained the writer lock! + if (!ITy) { + // Value not found. Derive a new type! + ITy = new IntegerType(NumBits); + IntegerTypes->add(IVT, ITy); } - } else { - ITy = IntegerTypes->get(IVT); - if (ITy) return ITy; // Found a match, return it! - - // Value not found. Derive a new type! - ITy = new IntegerType(NumBits); - IntegerTypes->add(IVT, ITy); } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *ITy << "\n"; @@ -1099,37 +1089,25 @@ FunctionValType VT(ReturnType, Params, isVarArg); FunctionType *FT = 0; - if (llvm_is_multithreaded()) { - TypeMapLock->reader_acquire(); - FT = FunctionTypes->get(VT); - TypeMapLock->reader_release(); + TypeMapLock->reader_acquire(); + FT = FunctionTypes->get(VT); + TypeMapLock->reader_release(); + + if (!FT) { + sys::SmartScopedWriter Writer(&*TypeMapLock); - if (!FT) { - TypeMapLock->writer_acquire(); - - // Have to check again here, because it might have - // been inserted between when we release the reader - // lock and when we acquired the writer lock. - FT = FunctionTypes->get(VT); - if (!FT) { - FT = (FunctionType*) operator new(sizeof(FunctionType) + - sizeof(PATypeHandle)*(Params.size()+1)); - new (FT) FunctionType(ReturnType, Params, isVarArg); - FunctionTypes->add(VT, FT); - } - TypeMapLock->writer_release(); - } - } else { + // Have to check again here, because it might have + // been inserted between when we release the reader + // lock and when we acquired the writer lock. FT = FunctionTypes->get(VT); - if (FT) - return FT; - - FT = (FunctionType*) operator new(sizeof(FunctionType) + + if (!FT) { + FT = (FunctionType*) operator new(sizeof(FunctionType) + sizeof(PATypeHandle)*(Params.size()+1)); - new (FT) FunctionType(ReturnType, Params, isVarArg); - FunctionTypes->add(VT, FT); + new (FT) FunctionType(ReturnType, Params, isVarArg); + FunctionTypes->add(VT, FT); + } } - + #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << FT << "\n"; #endif @@ -1170,28 +1148,19 @@ ArrayValType AVT(ElementType, NumElements); ArrayType *AT = 0; - if (llvm_is_multithreaded()) { - TypeMapLock->reader_acquire(); - AT = ArrayTypes->get(AVT); - TypeMapLock->reader_release(); + TypeMapLock->reader_acquire(); + AT = ArrayTypes->get(AVT); + TypeMapLock->reader_release(); + + if (!AT) { + sys::SmartScopedWriter Writer(&*TypeMapLock); + // Recheck. Might have changed between release and acquire. + AT = ArrayTypes->get(AVT); if (!AT) { - TypeMapLock->writer_acquire(); - - // Recheck. Might have changed between release and acquire. - AT = ArrayTypes->get(AVT); - if (!AT) { - // Value not found. Derive a new type! - ArrayTypes->add(AVT, AT = new ArrayType(ElementType, NumElements)); - } - TypeMapLock->writer_release(); + // Value not found. Derive a new type! + ArrayTypes->add(AVT, AT = new ArrayType(ElementType, NumElements)); } - } else { - AT = ArrayTypes->get(AVT); - if (AT) return AT; // Found a match, return it! - - // Value not found. Derive a new type! - ArrayTypes->add(AVT, AT = new ArrayType(ElementType, NumElements)); } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *AT << "\n"; @@ -1245,26 +1214,17 @@ VectorValType PVT(ElementType, NumElements); VectorType *PT = 0; - if (llvm_is_multithreaded()) { - TypeMapLock->reader_acquire(); - PT = VectorTypes->get(PVT); - TypeMapLock->reader_release(); + TypeMapLock->reader_acquire(); + PT = VectorTypes->get(PVT); + TypeMapLock->reader_release(); + if (!PT) { + sys::SmartScopedWriter Writer(&*TypeMapLock); + PT = VectorTypes->get(PVT); + // Recheck. Might have changed between release and acquire. if (!PT) { - TypeMapLock->writer_acquire(); - PT = VectorTypes->get(PVT); - // Recheck. Might have changed between release and acquire. - if (!PT) { - VectorTypes->add(PVT, PT = new VectorType(ElementType, NumElements)); - } - TypeMapLock->writer_acquire(); + VectorTypes->add(PVT, PT = new VectorType(ElementType, NumElements)); } - } else { - PT = VectorTypes->get(PVT); - if (PT) return PT; // Found a match, return it! - - // Value not found. Derive a new type! - VectorTypes->add(PVT, PT = new VectorType(ElementType, NumElements)); } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *PT << "\n"; @@ -1322,33 +1282,21 @@ StructValType STV(ETypes, isPacked); StructType *ST = 0; - if (llvm_is_multithreaded()) { - TypeMapLock->reader_acquire(); - ST = StructTypes->get(STV); - TypeMapLock->reader_release(); + TypeMapLock->reader_acquire(); + ST = StructTypes->get(STV); + TypeMapLock->reader_release(); + if (!ST) { + sys::SmartScopedWriter Writer(&*TypeMapLock); + ST = StructTypes->get(STV); + // Recheck. Might have changed between release and acquire. if (!ST) { - TypeMapLock->writer_acquire(); - ST = StructTypes->get(STV); - // Recheck. Might have changed between release and acquire. - if (!ST) { - // Value not found. Derive a new type! - ST = (StructType*) operator new(sizeof(StructType) + - sizeof(PATypeHandle) * ETypes.size()); - new (ST) StructType(ETypes, isPacked); - StructTypes->add(STV, ST); - } - TypeMapLock->writer_release(); + // Value not found. Derive a new type! + ST = (StructType*) operator new(sizeof(StructType) + + sizeof(PATypeHandle) * ETypes.size()); + new (ST) StructType(ETypes, isPacked); + StructTypes->add(STV, ST); } - } else { - ST = StructTypes->get(STV); - if (ST) return ST; - - // Value not found. Derive a new type! - ST = (StructType*) operator new(sizeof(StructType) + - sizeof(PATypeHandle) * ETypes.size()); - new (ST) StructType(ETypes, isPacked); - StructTypes->add(STV, ST); } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *ST << "\n"; @@ -1419,27 +1367,18 @@ PointerType *PT = 0; - if (llvm_is_multithreaded()) { - TypeMapLock->reader_acquire(); + TypeMapLock->reader_acquire(); + PT = PointerTypes->get(PVT); + TypeMapLock->reader_release(); + + if (!PT) { + sys::SmartScopedWriter Writer(&*TypeMapLock); PT = PointerTypes->get(PVT); - TypeMapLock->reader_release(); - + // Recheck. Might have changed between release and acquire. if (!PT) { - TypeMapLock->writer_acquire(); - PT = PointerTypes->get(PVT); - // Recheck. Might have changed between release and acquire. - if (!PT) { - // Value not found. Derive a new type! - PointerTypes->add(PVT, PT = new PointerType(ValueType, AddressSpace)); - } - TypeMapLock->writer_release(); + // Value not found. Derive a new type! + PointerTypes->add(PVT, PT = new PointerType(ValueType, AddressSpace)); } - } else { - PT = PointerTypes->get(PVT); - if (PT) return PT; - - // Value not found. Derive a new type! - PointerTypes->add(PVT, PT = new PointerType(ValueType, AddressSpace)); } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *PT << "\n"; @@ -1591,15 +1530,10 @@ // us that this abstract type is equivalent to another type. // void DerivedType::refineAbstractTypeTo(const Type *NewType) { - if (llvm_is_multithreaded()) { - // All recursive calls will go through unlockedRefineAbstractTypeTo, - // to avoid deadlock problems. - TypeMapLock->writer_acquire(); - unlockedRefineAbstractTypeTo(NewType); - TypeMapLock->writer_release(); - } else { - unlockedRefineAbstractTypeTo(NewType); - } + // All recursive calls will go through unlockedRefineAbstractTypeTo, + // to avoid deadlock problems. + sys::SmartScopedWriter Writer(&*TypeMapLock); + unlockedRefineAbstractTypeTo(NewType); } // notifyUsesThatTypeBecameConcrete - Notify AbstractTypeUsers of this type that From gohman at apple.com Thu Jun 18 15:21:22 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Jun 2009 20:21:22 -0000 Subject: [llvm-commits] [llvm] r73717 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200906182021.n5IKLNkf014362@zion.cs.uiuc.edu> Author: djg Date: Thu Jun 18 15:21:07 2009 New Revision: 73717 URL: http://llvm.org/viewvc/llvm-project?rev=73717&view=rev Log: Recognize n != 0 ? n : 1 as umax(n, 1). Previously only ULT/UGT/ULE/UGE comparisons were recognized for umax, but instcombine canonicalizes unsigned comparisons with zero to this simpler form. 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=73717&r1=73716&r2=73717&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Jun 18 15:21:07 2009 @@ -2580,6 +2580,24 @@ return getNotSCEV(getUMaxExpr(getNotSCEV(getSCEV(LHS)), getNotSCEV(getSCEV(RHS)))); break; + case ICmpInst::ICMP_NE: + // n != 0 ? n : 1 -> umax(n, 1) + if (LHS == U->getOperand(1) && + isa(U->getOperand(2)) && + cast(U->getOperand(2))->isOne() && + isa(RHS) && + cast(RHS)->isZero()) + return getUMaxExpr(getSCEV(LHS), getSCEV(U->getOperand(2))); + break; + case ICmpInst::ICMP_EQ: + // n == 0 ? 1 : n -> umax(n, 1) + if (LHS == U->getOperand(2) && + isa(U->getOperand(1)) && + cast(U->getOperand(1))->isOne() && + isa(RHS) && + cast(RHS)->isZero()) + return getUMaxExpr(getSCEV(LHS), getSCEV(U->getOperand(1))); + break; default: break; } From gohman at apple.com Thu Jun 18 15:23:19 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Jun 2009 20:23:19 -0000 Subject: [llvm-commits] [llvm] r73718 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/optimize-max-0.ll test/CodeGen/X86/optimize-max-1.ll test/CodeGen/X86/optimize-smax.ll Message-ID: <200906182023.n5IKNJ7K014489@zion.cs.uiuc.edu> Author: djg Date: Thu Jun 18 15:23:18 2009 New Revision: 73718 URL: http://llvm.org/viewvc/llvm-project?rev=73718&view=rev Log: Generalize LSR's OptimizeSMax to handle unsigned max tests as well as signed max tests. Along with r73717, this helps CodeGen avoid emitting code for a maximum operation for this class of loop. Added: llvm/trunk/test/CodeGen/X86/optimize-max-0.ll (contents, props changed) - copied, changed from r73708, llvm/trunk/test/CodeGen/X86/optimize-smax.ll llvm/trunk/test/CodeGen/X86/optimize-max-1.ll Removed: llvm/trunk/test/CodeGen/X86/optimize-smax.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=73718&r1=73717&r2=73718&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Thu Jun 18 15:23:18 2009 @@ -143,10 +143,10 @@ /// inside the loop then try to eliminate the cast opeation. void OptimizeShadowIV(Loop *L); - /// OptimizeSMax - Rewrite the loop's terminating condition - /// if it uses an smax computation. - ICmpInst *OptimizeSMax(Loop *L, ICmpInst *Cond, - IVStrideUse* &CondUse); + /// OptimizeMax - Rewrite the loop's terminating condition + /// if it uses a max computation. + ICmpInst *OptimizeMax(Loop *L, ICmpInst *Cond, + IVStrideUse* &CondUse); bool FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse, const SCEVHandle *&CondStride); @@ -2044,8 +2044,8 @@ return Cond; } -/// OptimizeSMax - Rewrite the loop's terminating condition if it uses -/// an smax computation. +/// OptimizeMax - Rewrite the loop's terminating condition if it uses +/// a max computation. /// /// This is a narrow solution to a specific, but acute, problem. For loops /// like this: @@ -2055,10 +2055,10 @@ /// p[i] = 0.0; /// } while (++i < n); /// -/// where the comparison is signed, the trip count isn't just 'n', because -/// 'n' could be negative. And unfortunately this can come up even for loops -/// where the user didn't use a C do-while loop. For example, seemingly -/// well-behaved top-test loops will commonly be lowered like this: +/// the trip count isn't just 'n', because 'n' might not be positive. And +/// unfortunately this can come up even for loops where the user didn't use +/// a C do-while loop. For example, seemingly well-behaved top-test loops +/// will commonly be lowered like this: // /// if (n > 0) { /// i = 0; @@ -2071,14 +2071,14 @@ /// test in such a way that indvars can't find it. /// /// When indvars can't find the if test in loops like this, it creates a -/// signed-max expression, which allows it to give the loop a canonical +/// max expression, which allows it to give the loop a canonical /// induction variable: /// /// i = 0; -/// smax = n < 1 ? 1 : n; +/// max = n < 1 ? 1 : n; /// do { /// p[i] = 0.0; -/// } while (++i != smax); +/// } while (++i != max); /// /// Canonical induction variables are necessary because the loop passes /// are designed around them. The most obvious example of this is the @@ -2094,8 +2094,8 @@ /// rewriting their conditions from ICMP_NE back to ICMP_SLT, and deleting /// the instructions for the maximum computation. /// -ICmpInst *LoopStrengthReduce::OptimizeSMax(Loop *L, ICmpInst *Cond, - IVStrideUse* &CondUse) { +ICmpInst *LoopStrengthReduce::OptimizeMax(Loop *L, ICmpInst *Cond, + IVStrideUse* &CondUse) { // Check that the loop matches the pattern we're looking for. if (Cond->getPredicate() != CmpInst::ICMP_EQ && Cond->getPredicate() != CmpInst::ICMP_NE) @@ -2113,12 +2113,14 @@ SCEVHandle IterationCount = SE->getAddExpr(BackedgeTakenCount, One); // Check for a max calculation that matches the pattern. - const SCEVSMaxExpr *SMax = dyn_cast(IterationCount); - if (!SMax || SMax != SE->getSCEV(Sel)) return Cond; + if (!isa(IterationCount) && !isa(IterationCount)) + return Cond; + const SCEVNAryExpr *Max = cast(IterationCount); + if (Max != SE->getSCEV(Sel)) return Cond; - SCEVHandle SMaxLHS = SMax->getOperand(0); - SCEVHandle SMaxRHS = SMax->getOperand(1); - if (!SMaxLHS || SMaxLHS != One) return Cond; + SCEVHandle MaxLHS = Max->getOperand(0); + SCEVHandle MaxRHS = Max->getOperand(1); + if (!MaxLHS || MaxLHS != One) return Cond; // Check the relevant induction variable for conformance to // the pattern. @@ -2135,19 +2137,23 @@ // Check the right operand of the select, and remember it, as it will // be used in the new comparison instruction. Value *NewRHS = 0; - if (SE->getSCEV(Sel->getOperand(1)) == SMaxRHS) + if (SE->getSCEV(Sel->getOperand(1)) == MaxRHS) NewRHS = Sel->getOperand(1); - else if (SE->getSCEV(Sel->getOperand(2)) == SMaxRHS) + else if (SE->getSCEV(Sel->getOperand(2)) == MaxRHS) NewRHS = Sel->getOperand(2); if (!NewRHS) return Cond; + // Determine the new comparison opcode. It may be signed or unsigned, + // and the original comparison may be either equality or inequality. + CmpInst::Predicate Pred = + isa(Max) ? CmpInst::ICMP_SLT : CmpInst::ICMP_ULT; + if (Cond->getPredicate() == CmpInst::ICMP_EQ) + Pred = CmpInst::getInversePredicate(Pred); + // Ok, everything looks ok to change the condition into an SLT or SGE and // delete the max calculation. ICmpInst *NewCond = - new ICmpInst(Cond->getPredicate() == CmpInst::ICMP_NE ? - CmpInst::ICMP_SLT : - CmpInst::ICMP_SGE, - Cond->getOperand(0), NewRHS, "scmp", Cond); + new ICmpInst(Pred, Cond->getOperand(0), NewRHS, "scmp", Cond); // Delete the max calculation instructions. Cond->replaceAllUsesWith(NewCond); @@ -2360,10 +2366,10 @@ StrideNoReuse.insert(*CondStride); } - // If the trip count is computed in terms of an smax (due to ScalarEvolution + // If the trip count is computed in terms of a max (due to ScalarEvolution // being unable to find a sufficient guard, for example), change the loop - // comparison to use SLT instead of NE. - Cond = OptimizeSMax(L, Cond, CondUse); + // comparison to use SLT or ULT instead of NE. + Cond = OptimizeMax(L, Cond, CondUse); // If possible, change stride and operands of the compare instruction to // eliminate one stride. Copied: llvm/trunk/test/CodeGen/X86/optimize-max-0.ll (from r73708, llvm/trunk/test/CodeGen/X86/optimize-smax.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/optimize-max-0.ll?p2=llvm/trunk/test/CodeGen/X86/optimize-max-0.ll&p1=llvm/trunk/test/CodeGen/X86/optimize-smax.ll&r1=73708&r2=73718&rev=73718&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/optimize-smax.ll (original) +++ llvm/trunk/test/CodeGen/X86/optimize-max-0.ll Thu Jun 18 15:23:18 2009 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -march=x86 | not grep cmov -; LSR should be able to eliminate the smax computations by -; making the loops use slt comparisons instead of ne comparisons. +; LSR should be able to eliminate the max computations by +; making the loops use slt/ult comparisons instead of ne comparisons. 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-darwin9" @@ -231,6 +231,231 @@ ret void } +define void @bar(i8* %r, i32 %s, i32 %w, i32 %x, i8* %j, i32 %d) nounwind { +entry: + %0 = mul i32 %x, %w ; [#uses=2] + %1 = mul i32 %x, %w ; [#uses=1] + %2 = udiv i32 %1, 4 ; [#uses=1] + %.sum2 = add i32 %2, %0 ; [#uses=2] + %cond = icmp eq i32 %d, 1 ; [#uses=1] + br i1 %cond, label %bb29, label %bb10.preheader + +bb10.preheader: ; preds = %entry + %3 = icmp ne i32 %x, 0 ; [#uses=1] + br i1 %3, label %bb.nph9, label %bb18.loopexit + +bb.nph7: ; preds = %bb7.preheader + %4 = mul i32 %y.08, %w ; [#uses=1] + %5 = mul i32 %y.08, %s ; [#uses=1] + %6 = add i32 %5, 1 ; [#uses=1] + %tmp8 = icmp ugt i32 1, %w ; [#uses=1] + %smax9 = select i1 %tmp8, i32 1, i32 %w ; [#uses=1] + br label %bb6 + +bb6: ; preds = %bb7, %bb.nph7 + %x.06 = phi i32 [ 0, %bb.nph7 ], [ %indvar.next7, %bb7 ] ; [#uses=3] + %7 = add i32 %x.06, %4 ; [#uses=1] + %8 = shl i32 %x.06, 1 ; [#uses=1] + %9 = add i32 %6, %8 ; [#uses=1] + %10 = getelementptr i8* %r, i32 %9 ; [#uses=1] + %11 = load i8* %10, align 1 ; [#uses=1] + %12 = getelementptr i8* %j, i32 %7 ; [#uses=1] + store i8 %11, i8* %12, align 1 + br label %bb7 + +bb7: ; preds = %bb6 + %indvar.next7 = add i32 %x.06, 1 ; [#uses=2] + %exitcond10 = icmp ne i32 %indvar.next7, %smax9 ; [#uses=1] + br i1 %exitcond10, label %bb6, label %bb7.bb9_crit_edge + +bb7.bb9_crit_edge: ; preds = %bb7 + br label %bb9 + +bb9: ; preds = %bb7.preheader, %bb7.bb9_crit_edge + br label %bb10 + +bb10: ; preds = %bb9 + %indvar.next11 = add i32 %y.08, 1 ; [#uses=2] + %exitcond12 = icmp ne i32 %indvar.next11, %x ; [#uses=1] + br i1 %exitcond12, label %bb7.preheader, label %bb10.bb18.loopexit_crit_edge + +bb10.bb18.loopexit_crit_edge: ; preds = %bb10 + br label %bb10.bb18.loopexit_crit_edge.split + +bb10.bb18.loopexit_crit_edge.split: ; preds = %bb.nph9, %bb10.bb18.loopexit_crit_edge + br label %bb18.loopexit + +bb.nph9: ; preds = %bb10.preheader + %13 = icmp ugt i32 %w, 0 ; [#uses=1] + br i1 %13, label %bb.nph9.split, label %bb10.bb18.loopexit_crit_edge.split + +bb.nph9.split: ; preds = %bb.nph9 + br label %bb7.preheader + +bb7.preheader: ; preds = %bb.nph9.split, %bb10 + %y.08 = phi i32 [ 0, %bb.nph9.split ], [ %indvar.next11, %bb10 ] ; [#uses=3] + br i1 true, label %bb.nph7, label %bb9 + +bb.nph5: ; preds = %bb18.loopexit + %14 = udiv i32 %w, 2 ; [#uses=1] + %15 = icmp ult i32 %w, 2 ; [#uses=1] + %16 = udiv i32 %x, 2 ; [#uses=2] + br i1 %15, label %bb18.bb20_crit_edge.split, label %bb.nph5.split + +bb.nph5.split: ; preds = %bb.nph5 + %tmp2 = icmp ugt i32 1, %16 ; [#uses=1] + %smax3 = select i1 %tmp2, i32 1, i32 %16 ; [#uses=1] + br label %bb13 + +bb13: ; preds = %bb18, %bb.nph5.split + %y.14 = phi i32 [ 0, %bb.nph5.split ], [ %indvar.next1, %bb18 ] ; [#uses=4] + %17 = mul i32 %14, %y.14 ; [#uses=2] + %18 = shl i32 %y.14, 1 ; [#uses=1] + %19 = urem i32 %y.14, 2 ; [#uses=1] + %20 = add i32 %19, %18 ; [#uses=1] + %21 = mul i32 %20, %s ; [#uses=2] + br i1 true, label %bb.nph3, label %bb17 + +bb.nph3: ; preds = %bb13 + %22 = add i32 %17, %0 ; [#uses=1] + %23 = add i32 %17, %.sum2 ; [#uses=1] + %24 = udiv i32 %w, 2 ; [#uses=2] + %tmp = icmp ugt i32 1, %24 ; [#uses=1] + %smax = select i1 %tmp, i32 1, i32 %24 ; [#uses=1] + br label %bb14 + +bb14: ; preds = %bb15, %bb.nph3 + %x.12 = phi i32 [ 0, %bb.nph3 ], [ %indvar.next, %bb15 ] ; [#uses=5] + %25 = shl i32 %x.12, 2 ; [#uses=1] + %26 = add i32 %25, %21 ; [#uses=1] + %27 = getelementptr i8* %r, i32 %26 ; [#uses=1] + %28 = load i8* %27, align 1 ; [#uses=1] + %.sum = add i32 %22, %x.12 ; [#uses=1] + %29 = getelementptr i8* %j, i32 %.sum ; [#uses=1] + store i8 %28, i8* %29, align 1 + %30 = shl i32 %x.12, 2 ; [#uses=1] + %31 = or i32 %30, 2 ; [#uses=1] + %32 = add i32 %31, %21 ; [#uses=1] + %33 = getelementptr i8* %r, i32 %32 ; [#uses=1] + %34 = load i8* %33, align 1 ; [#uses=1] + %.sum6 = add i32 %23, %x.12 ; [#uses=1] + %35 = getelementptr i8* %j, i32 %.sum6 ; [#uses=1] + store i8 %34, i8* %35, align 1 + br label %bb15 + +bb15: ; preds = %bb14 + %indvar.next = add i32 %x.12, 1 ; [#uses=2] + %exitcond = icmp ne i32 %indvar.next, %smax ; [#uses=1] + br i1 %exitcond, label %bb14, label %bb15.bb17_crit_edge + +bb15.bb17_crit_edge: ; preds = %bb15 + br label %bb17 + +bb17: ; preds = %bb15.bb17_crit_edge, %bb13 + br label %bb18 + +bb18.loopexit: ; preds = %bb10.bb18.loopexit_crit_edge.split, %bb10.preheader + %36 = icmp ult i32 %x, 2 ; [#uses=1] + br i1 %36, label %bb20, label %bb.nph5 + +bb18: ; preds = %bb17 + %indvar.next1 = add i32 %y.14, 1 ; [#uses=2] + %exitcond4 = icmp ne i32 %indvar.next1, %smax3 ; [#uses=1] + br i1 %exitcond4, label %bb13, label %bb18.bb20_crit_edge + +bb18.bb20_crit_edge: ; preds = %bb18 + br label %bb18.bb20_crit_edge.split + +bb18.bb20_crit_edge.split: ; preds = %bb18.bb20_crit_edge, %bb.nph5 + br label %bb20 + +bb20: ; preds = %bb18.bb20_crit_edge.split, %bb18.loopexit + switch i32 %d, label %return [ + i32 3, label %bb22 + i32 1, label %bb29 + ] + +bb22: ; preds = %bb20 + %37 = mul i32 %x, %w ; [#uses=1] + %38 = udiv i32 %37, 4 ; [#uses=1] + %.sum3 = add i32 %38, %.sum2 ; [#uses=2] + %39 = add i32 %x, 15 ; [#uses=1] + %40 = and i32 %39, -16 ; [#uses=1] + %41 = add i32 %w, 15 ; [#uses=1] + %42 = and i32 %41, -16 ; [#uses=1] + %43 = mul i32 %40, %s ; [#uses=1] + %44 = icmp ugt i32 %x, 0 ; [#uses=1] + br i1 %44, label %bb.nph, label %bb26 + +bb.nph: ; preds = %bb22 + br label %bb23 + +bb23: ; preds = %bb24, %bb.nph + %y.21 = phi i32 [ 0, %bb.nph ], [ %indvar.next5, %bb24 ] ; [#uses=3] + %45 = mul i32 %y.21, %42 ; [#uses=1] + %.sum1 = add i32 %45, %43 ; [#uses=1] + %46 = getelementptr i8* %r, i32 %.sum1 ; [#uses=1] + %47 = mul i32 %y.21, %w ; [#uses=1] + %.sum5 = add i32 %47, %.sum3 ; [#uses=1] + %48 = getelementptr i8* %j, i32 %.sum5 ; [#uses=1] + tail call void @llvm.memcpy.i32(i8* %48, i8* %46, i32 %w, i32 1) + br label %bb24 + +bb24: ; preds = %bb23 + %indvar.next5 = add i32 %y.21, 1 ; [#uses=2] + %exitcond6 = icmp ne i32 %indvar.next5, %x ; [#uses=1] + br i1 %exitcond6, label %bb23, label %bb24.bb26_crit_edge + +bb24.bb26_crit_edge: ; preds = %bb24 + br label %bb26 + +bb26: ; preds = %bb24.bb26_crit_edge, %bb22 + %49 = mul i32 %x, %w ; [#uses=1] + %.sum4 = add i32 %.sum3, %49 ; [#uses=1] + %50 = getelementptr i8* %j, i32 %.sum4 ; [#uses=1] + %51 = mul i32 %x, %w ; [#uses=1] + %52 = udiv i32 %51, 2 ; [#uses=1] + tail call void @llvm.memset.i32(i8* %50, i8 -128, i32 %52, i32 1) + ret void + +bb29: ; preds = %bb20, %entry + %53 = add i32 %w, 15 ; [#uses=1] + %54 = and i32 %53, -16 ; [#uses=1] + %55 = icmp ugt i32 %x, 0 ; [#uses=1] + br i1 %55, label %bb.nph11, label %bb33 + +bb.nph11: ; preds = %bb29 + br label %bb30 + +bb30: ; preds = %bb31, %bb.nph11 + %y.310 = phi i32 [ 0, %bb.nph11 ], [ %indvar.next13, %bb31 ] ; [#uses=3] + %56 = mul i32 %y.310, %54 ; [#uses=1] + %57 = getelementptr i8* %r, i32 %56 ; [#uses=1] + %58 = mul i32 %y.310, %w ; [#uses=1] + %59 = getelementptr i8* %j, i32 %58 ; [#uses=1] + tail call void @llvm.memcpy.i32(i8* %59, i8* %57, i32 %w, i32 1) + br label %bb31 + +bb31: ; preds = %bb30 + %indvar.next13 = add i32 %y.310, 1 ; [#uses=2] + %exitcond14 = icmp ne i32 %indvar.next13, %x ; [#uses=1] + br i1 %exitcond14, label %bb30, label %bb31.bb33_crit_edge + +bb31.bb33_crit_edge: ; preds = %bb31 + br label %bb33 + +bb33: ; preds = %bb31.bb33_crit_edge, %bb29 + %60 = mul i32 %x, %w ; [#uses=1] + %61 = getelementptr i8* %j, i32 %60 ; [#uses=1] + %62 = mul i32 %x, %w ; [#uses=1] + %63 = udiv i32 %62, 2 ; [#uses=1] + tail call void @llvm.memset.i32(i8* %61, i8 -128, i32 %63, i32 1) + ret void + +return: ; preds = %bb20 + ret void +} + declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind declare void @llvm.memset.i32(i8*, i8, i32, i32) nounwind Propchange: llvm/trunk/test/CodeGen/X86/optimize-max-0.ll ------------------------------------------------------------------------------ svn:mergeinfo = Added: llvm/trunk/test/CodeGen/X86/optimize-max-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/optimize-max-1.ll?rev=73718&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/optimize-max-1.ll (added) +++ llvm/trunk/test/CodeGen/X86/optimize-max-1.ll Thu Jun 18 15:23:18 2009 @@ -0,0 +1,78 @@ +; RUN: llvm-as < %s | llc -march=x86-64 | not grep cmov + +; LSR should be able to eliminate both smax and umax expressions +; in loop trip counts. + +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" + +define void @fs(double* nocapture %p, i64 %n) nounwind { +entry: + %tmp = icmp slt i64 %n, 1 ; [#uses=1] + %smax = select i1 %tmp, i64 1, i64 %n ; [#uses=1] + br label %bb + +bb: ; preds = %bb, %entry + %i.0 = phi i64 [ 0, %entry ], [ %0, %bb ] ; [#uses=2] + %scevgep = getelementptr double* %p, i64 %i.0 ; [#uses=1] + store double 0.000000e+00, double* %scevgep, align 8 + %0 = add i64 %i.0, 1 ; [#uses=2] + %exitcond = icmp eq i64 %0, %smax ; [#uses=1] + br i1 %exitcond, label %return, label %bb + +return: ; preds = %bb + ret void +} + +define void @bs(double* nocapture %p, i64 %n) nounwind { +entry: + %tmp = icmp sge i64 %n, 1 ; [#uses=1] + %smax = select i1 %tmp, i64 %n, i64 1 ; [#uses=1] + br label %bb + +bb: ; preds = %bb, %entry + %i.0 = phi i64 [ 0, %entry ], [ %0, %bb ] ; [#uses=2] + %scevgep = getelementptr double* %p, i64 %i.0 ; [#uses=1] + store double 0.000000e+00, double* %scevgep, align 8 + %0 = add i64 %i.0, 1 ; [#uses=2] + %exitcond = icmp eq i64 %0, %smax ; [#uses=1] + br i1 %exitcond, label %return, label %bb + +return: ; preds = %bb + ret void +} + +define void @fu(double* nocapture %p, i64 %n) nounwind { +entry: + %tmp = icmp eq i64 %n, 0 ; [#uses=1] + %umax = select i1 %tmp, i64 1, i64 %n ; [#uses=1] + br label %bb + +bb: ; preds = %bb, %entry + %i.0 = phi i64 [ 0, %entry ], [ %0, %bb ] ; [#uses=2] + %scevgep = getelementptr double* %p, i64 %i.0 ; [#uses=1] + store double 0.000000e+00, double* %scevgep, align 8 + %0 = add i64 %i.0, 1 ; [#uses=2] + %exitcond = icmp eq i64 %0, %umax ; [#uses=1] + br i1 %exitcond, label %return, label %bb + +return: ; preds = %bb + ret void +} + +define void @bu(double* nocapture %p, i64 %n) nounwind { +entry: + %tmp = icmp ne i64 %n, 0 ; [#uses=1] + %umax = select i1 %tmp, i64 %n, i64 1 ; [#uses=1] + br label %bb + +bb: ; preds = %bb, %entry + %i.0 = phi i64 [ 0, %entry ], [ %0, %bb ] ; [#uses=2] + %scevgep = getelementptr double* %p, i64 %i.0 ; [#uses=1] + store double 0.000000e+00, double* %scevgep, align 8 + %0 = add i64 %i.0, 1 ; [#uses=2] + %exitcond = icmp eq i64 %0, %umax ; [#uses=1] + br i1 %exitcond, label %return, label %bb + +return: ; preds = %bb + ret void +} Removed: llvm/trunk/test/CodeGen/X86/optimize-smax.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/optimize-smax.ll?rev=73717&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/optimize-smax.ll (original) +++ llvm/trunk/test/CodeGen/X86/optimize-smax.ll (removed) @@ -1,236 +0,0 @@ -; RUN: llvm-as < %s | llc -march=x86 | not grep cmov - -; LSR should be able to eliminate the smax computations by -; making the loops use slt comparisons instead of ne comparisons. - -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-darwin9" - -define void @foo(i8* %r, i32 %s, i32 %w, i32 %x, i8* %j, i32 %d) nounwind { -entry: - %0 = mul i32 %x, %w ; [#uses=2] - %1 = mul i32 %x, %w ; [#uses=1] - %2 = sdiv i32 %1, 4 ; [#uses=1] - %.sum2 = add i32 %2, %0 ; [#uses=2] - %cond = icmp eq i32 %d, 1 ; [#uses=1] - br i1 %cond, label %bb29, label %bb10.preheader - -bb10.preheader: ; preds = %entry - %3 = icmp sgt i32 %x, 0 ; [#uses=1] - br i1 %3, label %bb.nph9, label %bb18.loopexit - -bb.nph7: ; preds = %bb7.preheader - %4 = mul i32 %y.08, %w ; [#uses=1] - %5 = mul i32 %y.08, %s ; [#uses=1] - %6 = add i32 %5, 1 ; [#uses=1] - %tmp8 = icmp sgt i32 1, %w ; [#uses=1] - %smax9 = select i1 %tmp8, i32 1, i32 %w ; [#uses=1] - br label %bb6 - -bb6: ; preds = %bb7, %bb.nph7 - %x.06 = phi i32 [ 0, %bb.nph7 ], [ %indvar.next7, %bb7 ] ; [#uses=3] - %7 = add i32 %x.06, %4 ; [#uses=1] - %8 = shl i32 %x.06, 1 ; [#uses=1] - %9 = add i32 %6, %8 ; [#uses=1] - %10 = getelementptr i8* %r, i32 %9 ; [#uses=1] - %11 = load i8* %10, align 1 ; [#uses=1] - %12 = getelementptr i8* %j, i32 %7 ; [#uses=1] - store i8 %11, i8* %12, align 1 - br label %bb7 - -bb7: ; preds = %bb6 - %indvar.next7 = add i32 %x.06, 1 ; [#uses=2] - %exitcond10 = icmp ne i32 %indvar.next7, %smax9 ; [#uses=1] - br i1 %exitcond10, label %bb6, label %bb7.bb9_crit_edge - -bb7.bb9_crit_edge: ; preds = %bb7 - br label %bb9 - -bb9: ; preds = %bb7.preheader, %bb7.bb9_crit_edge - br label %bb10 - -bb10: ; preds = %bb9 - %indvar.next11 = add i32 %y.08, 1 ; [#uses=2] - %exitcond12 = icmp ne i32 %indvar.next11, %x ; [#uses=1] - br i1 %exitcond12, label %bb7.preheader, label %bb10.bb18.loopexit_crit_edge - -bb10.bb18.loopexit_crit_edge: ; preds = %bb10 - br label %bb10.bb18.loopexit_crit_edge.split - -bb10.bb18.loopexit_crit_edge.split: ; preds = %bb.nph9, %bb10.bb18.loopexit_crit_edge - br label %bb18.loopexit - -bb.nph9: ; preds = %bb10.preheader - %13 = icmp sgt i32 %w, 0 ; [#uses=1] - br i1 %13, label %bb.nph9.split, label %bb10.bb18.loopexit_crit_edge.split - -bb.nph9.split: ; preds = %bb.nph9 - br label %bb7.preheader - -bb7.preheader: ; preds = %bb.nph9.split, %bb10 - %y.08 = phi i32 [ 0, %bb.nph9.split ], [ %indvar.next11, %bb10 ] ; [#uses=3] - br i1 true, label %bb.nph7, label %bb9 - -bb.nph5: ; preds = %bb18.loopexit - %14 = sdiv i32 %w, 2 ; [#uses=1] - %15 = icmp slt i32 %w, 2 ; [#uses=1] - %16 = sdiv i32 %x, 2 ; [#uses=2] - br i1 %15, label %bb18.bb20_crit_edge.split, label %bb.nph5.split - -bb.nph5.split: ; preds = %bb.nph5 - %tmp2 = icmp sgt i32 1, %16 ; [#uses=1] - %smax3 = select i1 %tmp2, i32 1, i32 %16 ; [#uses=1] - br label %bb13 - -bb13: ; preds = %bb18, %bb.nph5.split - %y.14 = phi i32 [ 0, %bb.nph5.split ], [ %indvar.next1, %bb18 ] ; [#uses=4] - %17 = mul i32 %14, %y.14 ; [#uses=2] - %18 = shl i32 %y.14, 1 ; [#uses=1] - %19 = srem i32 %y.14, 2 ; [#uses=1] - %20 = add i32 %19, %18 ; [#uses=1] - %21 = mul i32 %20, %s ; [#uses=2] - br i1 true, label %bb.nph3, label %bb17 - -bb.nph3: ; preds = %bb13 - %22 = add i32 %17, %0 ; [#uses=1] - %23 = add i32 %17, %.sum2 ; [#uses=1] - %24 = sdiv i32 %w, 2 ; [#uses=2] - %tmp = icmp sgt i32 1, %24 ; [#uses=1] - %smax = select i1 %tmp, i32 1, i32 %24 ; [#uses=1] - br label %bb14 - -bb14: ; preds = %bb15, %bb.nph3 - %x.12 = phi i32 [ 0, %bb.nph3 ], [ %indvar.next, %bb15 ] ; [#uses=5] - %25 = shl i32 %x.12, 2 ; [#uses=1] - %26 = add i32 %25, %21 ; [#uses=1] - %27 = getelementptr i8* %r, i32 %26 ; [#uses=1] - %28 = load i8* %27, align 1 ; [#uses=1] - %.sum = add i32 %22, %x.12 ; [#uses=1] - %29 = getelementptr i8* %j, i32 %.sum ; [#uses=1] - store i8 %28, i8* %29, align 1 - %30 = shl i32 %x.12, 2 ; [#uses=1] - %31 = or i32 %30, 2 ; [#uses=1] - %32 = add i32 %31, %21 ; [#uses=1] - %33 = getelementptr i8* %r, i32 %32 ; [#uses=1] - %34 = load i8* %33, align 1 ; [#uses=1] - %.sum6 = add i32 %23, %x.12 ; [#uses=1] - %35 = getelementptr i8* %j, i32 %.sum6 ; [#uses=1] - store i8 %34, i8* %35, align 1 - br label %bb15 - -bb15: ; preds = %bb14 - %indvar.next = add i32 %x.12, 1 ; [#uses=2] - %exitcond = icmp ne i32 %indvar.next, %smax ; [#uses=1] - br i1 %exitcond, label %bb14, label %bb15.bb17_crit_edge - -bb15.bb17_crit_edge: ; preds = %bb15 - br label %bb17 - -bb17: ; preds = %bb15.bb17_crit_edge, %bb13 - br label %bb18 - -bb18.loopexit: ; preds = %bb10.bb18.loopexit_crit_edge.split, %bb10.preheader - %36 = icmp slt i32 %x, 2 ; [#uses=1] - br i1 %36, label %bb20, label %bb.nph5 - -bb18: ; preds = %bb17 - %indvar.next1 = add i32 %y.14, 1 ; [#uses=2] - %exitcond4 = icmp ne i32 %indvar.next1, %smax3 ; [#uses=1] - br i1 %exitcond4, label %bb13, label %bb18.bb20_crit_edge - -bb18.bb20_crit_edge: ; preds = %bb18 - br label %bb18.bb20_crit_edge.split - -bb18.bb20_crit_edge.split: ; preds = %bb18.bb20_crit_edge, %bb.nph5 - br label %bb20 - -bb20: ; preds = %bb18.bb20_crit_edge.split, %bb18.loopexit - switch i32 %d, label %return [ - i32 3, label %bb22 - i32 1, label %bb29 - ] - -bb22: ; preds = %bb20 - %37 = mul i32 %x, %w ; [#uses=1] - %38 = sdiv i32 %37, 4 ; [#uses=1] - %.sum3 = add i32 %38, %.sum2 ; [#uses=2] - %39 = add i32 %x, 15 ; [#uses=1] - %40 = and i32 %39, -16 ; [#uses=1] - %41 = add i32 %w, 15 ; [#uses=1] - %42 = and i32 %41, -16 ; [#uses=1] - %43 = mul i32 %40, %s ; [#uses=1] - %44 = icmp sgt i32 %x, 0 ; [#uses=1] - br i1 %44, label %bb.nph, label %bb26 - -bb.nph: ; preds = %bb22 - br label %bb23 - -bb23: ; preds = %bb24, %bb.nph - %y.21 = phi i32 [ 0, %bb.nph ], [ %indvar.next5, %bb24 ] ; [#uses=3] - %45 = mul i32 %y.21, %42 ; [#uses=1] - %.sum1 = add i32 %45, %43 ; [#uses=1] - %46 = getelementptr i8* %r, i32 %.sum1 ; [#uses=1] - %47 = mul i32 %y.21, %w ; [#uses=1] - %.sum5 = add i32 %47, %.sum3 ; [#uses=1] - %48 = getelementptr i8* %j, i32 %.sum5 ; [#uses=1] - tail call void @llvm.memcpy.i32(i8* %48, i8* %46, i32 %w, i32 1) - br label %bb24 - -bb24: ; preds = %bb23 - %indvar.next5 = add i32 %y.21, 1 ; [#uses=2] - %exitcond6 = icmp ne i32 %indvar.next5, %x ; [#uses=1] - br i1 %exitcond6, label %bb23, label %bb24.bb26_crit_edge - -bb24.bb26_crit_edge: ; preds = %bb24 - br label %bb26 - -bb26: ; preds = %bb24.bb26_crit_edge, %bb22 - %49 = mul i32 %x, %w ; [#uses=1] - %.sum4 = add i32 %.sum3, %49 ; [#uses=1] - %50 = getelementptr i8* %j, i32 %.sum4 ; [#uses=1] - %51 = mul i32 %x, %w ; [#uses=1] - %52 = sdiv i32 %51, 2 ; [#uses=1] - tail call void @llvm.memset.i32(i8* %50, i8 -128, i32 %52, i32 1) - ret void - -bb29: ; preds = %bb20, %entry - %53 = add i32 %w, 15 ; [#uses=1] - %54 = and i32 %53, -16 ; [#uses=1] - %55 = icmp sgt i32 %x, 0 ; [#uses=1] - br i1 %55, label %bb.nph11, label %bb33 - -bb.nph11: ; preds = %bb29 - br label %bb30 - -bb30: ; preds = %bb31, %bb.nph11 - %y.310 = phi i32 [ 0, %bb.nph11 ], [ %indvar.next13, %bb31 ] ; [#uses=3] - %56 = mul i32 %y.310, %54 ; [#uses=1] - %57 = getelementptr i8* %r, i32 %56 ; [#uses=1] - %58 = mul i32 %y.310, %w ; [#uses=1] - %59 = getelementptr i8* %j, i32 %58 ; [#uses=1] - tail call void @llvm.memcpy.i32(i8* %59, i8* %57, i32 %w, i32 1) - br label %bb31 - -bb31: ; preds = %bb30 - %indvar.next13 = add i32 %y.310, 1 ; [#uses=2] - %exitcond14 = icmp ne i32 %indvar.next13, %x ; [#uses=1] - br i1 %exitcond14, label %bb30, label %bb31.bb33_crit_edge - -bb31.bb33_crit_edge: ; preds = %bb31 - br label %bb33 - -bb33: ; preds = %bb31.bb33_crit_edge, %bb29 - %60 = mul i32 %x, %w ; [#uses=1] - %61 = getelementptr i8* %j, i32 %60 ; [#uses=1] - %62 = mul i32 %x, %w ; [#uses=1] - %63 = sdiv i32 %62, 2 ; [#uses=1] - tail call void @llvm.memset.i32(i8* %61, i8 -128, i32 %63, i32 1) - ret void - -return: ; preds = %bb20 - ret void -} - -declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind - -declare void @llvm.memset.i32(i8*, i8, i32, i32) nounwind From gohman at apple.com Thu Jun 18 15:27:52 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 18 Jun 2009 13:27:52 -0700 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) In-Reply-To: <4A39EE9C.5070406@gmail.com> References: <4A393785.8090202@gmail.com> <6C8ECC3B-BE0E-4D05-92B4-926E9FF6CD8B@apple.com> <4A3955A9.4040300@gmail.com> <25637945-0AD3-4F9C-9C96-DB4AB9A4CCC7@apple.com> <4A39EE9C.5070406@gmail.com> Message-ID: On Jun 18, 2009, at 12:37 AM, T?r?k Edwin wrote: > On 2009-06-18 01:12, Dan Gohman wrote: > >> On Jun 17, 2009, at 1:44 PM, T?r?k Edwin wrote: >> >> >> >> >> >> >> >>> On 2009-06-17 23:25, Dan Gohman wrote: >>> >>> >>> >>> >>> >>>> On Jun 17, 2009, at 11:35 AM, T?r?k Edwin wrote: >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>>> Hi, >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't >>>>> >>>>> >>>>> >>>>> folded, >>>>> >>>>> >>>>> >>>>> the attached patch folds this into: >>>>> >>>>> >>>>> >>>>> umax (zext t1 %X to %t0, zext t1 %Y to %t0). >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext >>>>> >>>>> t1 >>>>> >>>>> >>>>> >>>>> (umax (%X, %Y)) to %t0. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> zext is very often encountered in SCEV expressions on x86-64, >>>>> since >>>>> >>>>> >>>>> >>>>> pointer indexes for GEP are i64. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> Thoughts? >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>> Another question to ask is whether this kind of thing belongs in >>>> >>>> >>>> >>>> ScalarEvolution, or if it would be more appropriate for >>>> >>>> >>>> >>>> instcombine. Instcombine looks at all instructions in a program, >>>> >>>> >>>> >>>> while ScalarEvolution typically only looks at those related to >>>> >>>> >>>> >>>> loop iteration. Also, instcombine could more easily handle more >>>> >>>> >>>> >>>> generalized cases of this optimization, for example with umin. >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> On the other hand, there are cases where it makes sense to do >>>> >>>> >>>> >>>> such simplifications in ScalarEvolution. Can you given an >>>> >>>> >>>> >>>> example where you're seeing this kind of code? >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>> It doesn't have much to do with code generation/optimization, but >>> >>> rather >>> >>> with analysis. >>> >>> I have a pass that tries to find buffer overflow bugs, doing that >>> >>> involves lots of umax() expressions. >>> >>> If I can move the zext out of umax I can decide quite early that an >>> >>> access is valid: >>> >>> >>> >>> int foo(unsigned n, unsigned i) >>> >>> { >>> >>> char *a = malloc(n); >>> >>> if (!a) >>> >>> return -1; >>> >>> if (i < n) >>> >>> a[i]=0; >>> >>> } >>> >>> >>> >> >> >> Where does the umax come from in this code? I guess that you're >> >> transforming it in some way; could you show what the code looks >> >> like after the transformation? >> >> >> > > %0 = malloc i8, i32 %n ; [#uses=2] > %2 = zext i32 %i to i64 ; [#uses=1] > %3 = getelementptr i8* %0, i64 %2 ; [#uses=1] > > %3 is '((zext i32 %i to i64) + %0' according to SCEV, > %0 has size %n => > > offset is (zext i32 %i to i64), hence one of the safety conditions > is i > >> = 0 && i < n. We already have i >= 0 since I treat all >> > values as unsigned, so that leaves us with i < n: > > if ((zext i32 %n to i64) umax (zext i32 %i to i64)) == (zext i32 %i to > i64) then access is always valid > if ((zext i32 %n to i64) umax (zext i32 %i to i64)) == (zext i32 %n to > i64) then access is always invalid Thanks, though it's still not clear why umax is needed. Wouldn't the code be a lot simpler expanded like this: if (zext %i to i64) < (zext %n to i64) then access is always valid else access is always invalid Stripping out the zexts from comparisons is fairly trivial. > Otherwise I use a solver to decide > > There are 2 more conditions (access size < size, offset + > access_size < > size) with similar expressions. > As I said I could do the zext simplification in my pass only, but I > thought this is something that would benefit SCEV(Expander) in > general. I agree that the transformation sounds more generally applicable, though umax is relatively uncommon in common SCEV usage, so I was curious where you were seeing this kind of expression. Having SCEVExpander do clever things is fine, though it's often easier to just let it expand expressions in a simple way and let a subsequent instcombine run tidy things up. Dan From resistor at mac.com Thu Jun 18 15:36:23 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 20:36:23 -0000 Subject: [llvm-commits] [llvm] r73719 - /llvm/trunk/lib/VMCore/Value.cpp Message-ID: <200906182036.n5IKaNJf014971@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 15:36:21 2009 New Revision: 73719 URL: http://llvm.org/viewvc/llvm-project?rev=73719&view=rev Log: Simplify by using no-op-when-not-multithreaded locks. Modified: llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=73719&r1=73718&r2=73719&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Thu Jun 18 15:36:21 2009 @@ -407,7 +407,7 @@ /// not a value has an entry in this map. typedef DenseMap ValueHandlesTy; static ManagedStatic ValueHandles; -static ManagedStatic ValueHandlesLock; +static ManagedStatic > ValueHandlesLock; /// AddToExistingUseList - Add this ValueHandle to the use list for VP, where /// List is known to point into the existing use list. @@ -430,11 +430,10 @@ if (VP->HasValueHandle) { // If this value already has a ValueHandle, then it must be in the // ValueHandles map already. - if (llvm_is_multithreaded()) ValueHandlesLock->reader_acquire(); + sys::SmartScopedReader Reader(&*ValueHandlesLock); ValueHandleBase *&Entry = (*ValueHandles)[VP]; assert(Entry != 0 && "Value doesn't have any handles?"); AddToExistingUseList(&Entry); - if (llvm_is_multithreaded()) ValueHandlesLock->reader_release(); return; } @@ -443,7 +442,7 @@ // reallocate itself, which would invalidate all of the PrevP pointers that // point into the old table. Handle this by checking for reallocation and // updating the stale pointers only if needed. - if (llvm_is_multithreaded()) ValueHandlesLock->writer_acquire(); + sys::SmartScopedWriter Writer(&*ValueHandlesLock); ValueHandlesTy &Handles = *ValueHandles; const void *OldBucketPtr = Handles.getPointerIntoBucketsArray(); @@ -456,7 +455,6 @@ // walk the table. if (Handles.isPointerIntoBucketsArray(OldBucketPtr) || Handles.size() == 1) { - if (llvm_is_multithreaded()) ValueHandlesLock->writer_release(); return; } @@ -466,8 +464,6 @@ assert(I->second && I->first == I->second->VP && "List invariant broken!"); I->second->setPrevPtr(&I->second); } - - if (llvm_is_multithreaded()) ValueHandlesLock->writer_release(); } /// RemoveFromUseList - Remove this ValueHandle from its current use list. @@ -488,13 +484,12 @@ // If the Next pointer was null, then it is possible that this was the last // ValueHandle watching VP. If so, delete its entry from the ValueHandles // map. - if (llvm_is_multithreaded()) ValueHandlesLock->writer_acquire(); + sys::SmartScopedWriter Writer(&*ValueHandlesLock); ValueHandlesTy &Handles = *ValueHandles; if (Handles.isPointerIntoBucketsArray(PrevPtr)) { Handles.erase(VP); VP->HasValueHandle = false; } - if (llvm_is_multithreaded()) ValueHandlesLock->writer_release(); } @@ -503,9 +498,9 @@ // Get the linked list base, which is guaranteed to exist since the // HasValueHandle flag is set. - if (llvm_is_multithreaded()) ValueHandlesLock->reader_acquire(); + ValueHandlesLock->reader_acquire(); ValueHandleBase *Entry = (*ValueHandles)[V]; - if (llvm_is_multithreaded()) ValueHandlesLock->reader_release(); + ValueHandlesLock->reader_release(); assert(Entry && "Value bit set but no entries exist"); while (Entry) { @@ -543,9 +538,9 @@ // Get the linked list base, which is guaranteed to exist since the // HasValueHandle flag is set. - if (llvm_is_multithreaded()) ValueHandlesLock->reader_acquire(); + ValueHandlesLock->reader_acquire(); ValueHandleBase *Entry = (*ValueHandles)[Old]; - if (llvm_is_multithreaded()) ValueHandlesLock->reader_release(); + ValueHandlesLock->reader_release(); assert(Entry && "Value bit set but no entries exist"); while (Entry) { From evan.cheng at apple.com Thu Jun 18 15:37:16 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 18 Jun 2009 20:37:16 -0000 Subject: [llvm-commits] [llvm] r73720 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/ARM/ARMTargetAsmInfo.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/X86/X86TargetAsmInfo.cpp test/CodeGen/X86/pic_jumptable.ll Message-ID: <200906182037.n5IKbGXE015007@zion.cs.uiuc.edu> Author: evancheng Date: Thu Jun 18 15:37:15 2009 New Revision: 73720 URL: http://llvm.org/viewvc/llvm-project?rev=73720&view=rev Log: On Darwin, ams printer should output a second label before a jump table so the linker knows it's a new atom. But this is only needed if the jump table is put in a separate section from the function body. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp llvm/trunk/test/CodeGen/X86/pic_jumptable.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=73720&r1=73719&r2=73720&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Jun 18 15:37:15 2009 @@ -347,8 +347,9 @@ const char* JumpTableDataSection = TAI->getJumpTableDataSection(); const Function *F = MF.getFunction(); unsigned SectionFlags = TAI->SectionFlagsForGlobal(F); + bool JTInDiffSection = false; if ((IsPic && !(LoweringInfo && LoweringInfo->usesGlobalOffsetTable())) || - !JumpTableDataSection || + !JumpTableDataSection || SectionFlags & SectionFlags::Linkonce) { // In PIC mode, we need to emit the jump table to the same section as the // function body itself, otherwise the label differences won't make sense. @@ -357,6 +358,7 @@ SwitchToSection(TAI->SectionForGlobal(F)); } else { SwitchToDataSection(JumpTableDataSection); + JTInDiffSection = true; } EmitAlignment(Log2_32(MJTI->getAlignment())); @@ -380,8 +382,10 @@ // before each jump table. The first label is never referenced, but tells // the assembler and linker the extents of the jump table object. The // second label is actually referenced by the code. - if (const char *JTLabelPrefix = TAI->getJumpTableSpecialLabelPrefix()) - O << JTLabelPrefix << "JTI" << getFunctionNumber() << '_' << i << ":\n"; + if (JTInDiffSection) { + if (const char *JTLabelPrefix = TAI->getJumpTableSpecialLabelPrefix()) + O << JTLabelPrefix << "JTI" << getFunctionNumber() << '_' << i << ":\n"; + } O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' << i << ":\n"; Modified: llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp?rev=73720&r1=73719&r2=73720&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp Thu Jun 18 15:37:15 2009 @@ -74,10 +74,10 @@ // In non-PIC modes, emit a special label before jump tables so that the // linker can perform more accurate dead code stripping. - if (TM.getRelocationModel() != Reloc::PIC_) { - // Emit a local label that is preserved until the linker runs. - JumpTableSpecialLabelPrefix = "l"; - } + // Emit a local label that is preserved until the linker runs. + // We do not check the relocation model here since it can be overridden + // later. + JumpTableSpecialLabelPrefix = "l"; NeedsSet = true; DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp?rev=73720&r1=73719&r2=73720&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Thu Jun 18 15:37:15 2009 @@ -68,10 +68,9 @@ // In non-PIC modes, emit a special label before jump tables so that the // linker can perform more accurate dead code stripping. - if (TM.getRelocationModel() != Reloc::PIC_) { - // Emit a local label that is preserved until the linker runs. - JumpTableSpecialLabelPrefix = "l"; - } + // We do not check the relocation model here since it can be overridden + // later. + JumpTableSpecialLabelPrefix = "l"; } /// PreferredEHDataFormat - This hook allows the target to select data Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=73720&r1=73719&r2=73720&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Thu Jun 18 15:37:15 2009 @@ -99,10 +99,10 @@ // In non-PIC modes, emit a special label before jump tables so that the // linker can perform more accurate dead code stripping. - if (TM.getRelocationModel() != Reloc::PIC_) { - // Emit a local label that is preserved until the linker runs. - JumpTableSpecialLabelPrefix = "l"; - } + // Emit a local label that is preserved until the linker runs. + // We do not check the relocation model here since it can be overridden + // later. + JumpTableSpecialLabelPrefix = "l"; SupportsDebugInformation = true; NeedsSet = true; Modified: llvm/trunk/test/CodeGen/X86/pic_jumptable.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pic_jumptable.ll?rev=73720&r1=73719&r2=73720&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/pic_jumptable.ll (original) +++ llvm/trunk/test/CodeGen/X86/pic_jumptable.ll Thu Jun 18 15:37:15 2009 @@ -1,6 +1,8 @@ ; RUN: llvm-as < %s | llc -relocation-model=pic -mtriple=i386-linux-gnu -asm-verbose=false | not grep -F .text ; RUN: llvm-as < %s | llc -relocation-model=pic -mtriple=i686-apple-darwin -asm-verbose=false | not grep lea ; RUN: llvm-as < %s | llc -relocation-model=pic -mtriple=i686-apple-darwin -asm-verbose=false | grep add | count 2 +; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | not grep 'lJTI' +; rdar://6971437 declare void @_Z3bari(i32) From resistor at mac.com Thu Jun 18 15:44:31 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 20:44:31 -0000 Subject: [llvm-commits] [llvm] r73721 - /llvm/trunk/lib/VMCore/TypeSymbolTable.cpp Message-ID: <200906182044.n5IKiV2p015393@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 15:44:31 2009 New Revision: 73721 URL: http://llvm.org/viewvc/llvm-project?rev=73721&view=rev Log: Simplify with SmartRWMutex. Modified: llvm/trunk/lib/VMCore/TypeSymbolTable.cpp Modified: llvm/trunk/lib/VMCore/TypeSymbolTable.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/TypeSymbolTable.cpp?rev=73721&r1=73720&r2=73721&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/TypeSymbolTable.cpp (original) +++ llvm/trunk/lib/VMCore/TypeSymbolTable.cpp Thu Jun 18 15:44:31 2009 @@ -24,7 +24,7 @@ #define DEBUG_SYMBOL_TABLE 0 #define DEBUG_ABSTYPE 0 -static ManagedStatic TypeSymbolTableLock; +static ManagedStatic > TypeSymbolTableLock; TypeSymbolTable::~TypeSymbolTable() { // Drop all abstract type references in the type plane... @@ -37,36 +37,30 @@ std::string TypeSymbolTable::getUniqueName(const std::string &BaseName) const { std::string TryName = BaseName; - if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_acquire(); + sys::SmartScopedReader Reader(&*TypeSymbolTableLock); const_iterator End = tmap.end(); // See if the name exists while (tmap.find(TryName) != End) // Loop until we find a free TryName = BaseName + utostr(++LastUnique); // name in the symbol table - - if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_release(); - return TryName; } // lookup a type by name - returns null on failure Type* TypeSymbolTable::lookup(const std::string& Name) const { - if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_acquire(); + sys::SmartScopedReader Reader(&*TypeSymbolTableLock); const_iterator TI = tmap.find(Name); Type* result = 0; if (TI != tmap.end()) result = const_cast(TI->second); - - if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_release(); - return result; } // remove - Remove a type from the symbol table... Type* TypeSymbolTable::remove(iterator Entry) { - if (llvm_is_multithreaded()) TypeSymbolTableLock->writer_acquire(); + TypeSymbolTableLock->writer_acquire(); assert(Entry != tmap.end() && "Invalid entry to remove!"); const Type* Result = Entry->second; @@ -78,7 +72,7 @@ tmap.erase(Entry); - if (llvm_is_multithreaded()) TypeSymbolTableLock->writer_release(); + TypeSymbolTableLock->writer_release(); // If we are removing an abstract type, remove the symbol table from it's use // list... @@ -99,7 +93,7 @@ void TypeSymbolTable::insert(const std::string& Name, const Type* T) { assert(T && "Can't insert null type into symbol table!"); - if (llvm_is_multithreaded()) TypeSymbolTableLock->writer_acquire(); + TypeSymbolTableLock->writer_acquire(); if (tmap.insert(make_pair(Name, T)).second) { // Type inserted fine with no conflict. @@ -126,7 +120,7 @@ tmap.insert(make_pair(UniqueName, T)); } - if (llvm_is_multithreaded()) TypeSymbolTableLock->writer_release(); + TypeSymbolTableLock->writer_release(); // If we are adding an abstract type, add the symbol table to it's use list. if (T->isAbstract()) { @@ -140,8 +134,8 @@ // This function is called when one of the types in the type plane are refined void TypeSymbolTable::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_acquire(); - + sys::SmartScopedReader Reader(&*TypeSymbolTableLock); + // Loop over all of the types in the symbol table, replacing any references // to OldType with references to NewType. Note that there may be multiple // occurrences, and although we only need to remove one at a time, it's @@ -163,8 +157,6 @@ } } } - - if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_release(); } @@ -173,11 +165,10 @@ // Loop over all of the types in the symbol table, dropping any abstract // type user entries for AbsTy which occur because there are names for the // type. - if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_acquire(); + sys::SmartScopedReader Reader(&*TypeSymbolTableLock); for (iterator TI = begin(), TE = end(); TI != TE; ++TI) if (TI->second == const_cast(static_cast(AbsTy))) AbsTy->removeAbstractTypeUser(this); - if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_release(); } static void DumpTypes(const std::pair& T ) { @@ -188,9 +179,8 @@ void TypeSymbolTable::dump() const { cerr << "TypeSymbolPlane: "; - if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_acquire(); + sys::SmartScopedReader Reader(&*TypeSymbolTableLock); for_each(tmap.begin(), tmap.end(), DumpTypes); - if (llvm_is_multithreaded()) TypeSymbolTableLock->reader_release(); } // vim: sw=2 ai From resistor at mac.com Thu Jun 18 15:51:01 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 20:51:01 -0000 Subject: [llvm-commits] [llvm] r73722 - in /llvm/trunk: include/llvm/System/Mutex.h lib/VMCore/PassManager.cpp Message-ID: <200906182051.n5IKp1Ya015771@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 15:51:00 2009 New Revision: 73722 URL: http://llvm.org/viewvc/llvm-project?rev=73722&view=rev Log: Add a SmartScopedLock, and use it to simplify code. Modified: llvm/trunk/include/llvm/System/Mutex.h llvm/trunk/lib/VMCore/PassManager.cpp Modified: llvm/trunk/include/llvm/System/Mutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Mutex.h?rev=73722&r1=73721&r2=73722&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Mutex.h (original) +++ llvm/trunk/include/llvm/System/Mutex.h Thu Jun 18 15:51:00 2009 @@ -115,6 +115,22 @@ /// Mutex - A standard, always enforced mutex. typedef SmartMutex Mutex; + + template + class SmartScopedLock { + SmartMutex* mtx; + + public: + SmartScopedLock(SmartMutex* m) : mtx(m) { + mtx->acquire(); + } + + ~SmartScopedLock() { + mtx->release(); + } + }; + + typedef SmartScopedLock ScopedLock; } } Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=73722&r1=73721&r2=73722&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Thu Jun 18 15:51:00 2009 @@ -358,7 +358,7 @@ /// -time-passes is enabled on the command line. /// -static ManagedStatic TimingInfoMutex; +static ManagedStatic > TimingInfoMutex; class VISIBILITY_HIDDEN TimingInfo { std::map TimingData; @@ -384,22 +384,21 @@ if (dynamic_cast(P)) return; - if (llvm_is_multithreaded()) TimingInfoMutex->acquire(); + sys::SmartScopedLock Lock(&*TimingInfoMutex); std::map::iterator I = TimingData.find(P); if (I == TimingData.end()) I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first; I->second.startTimer(); - if (llvm_is_multithreaded()) TimingInfoMutex->release(); } + void passEnded(Pass *P) { if (dynamic_cast(P)) return; - if (llvm_is_multithreaded()) TimingInfoMutex->acquire(); + sys::SmartScopedLock Lock(&*TimingInfoMutex); std::map::iterator I = TimingData.find(P); assert(I != TimingData.end() && "passStarted/passEnded not nested right!"); I->second.stopTimer(); - if (llvm_is_multithreaded()) TimingInfoMutex->release(); } }; From resistor at mac.com Thu Jun 18 15:56:48 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 20:56:48 -0000 Subject: [llvm-commits] [llvm] r73723 - /llvm/trunk/lib/VMCore/Function.cpp Message-ID: <200906182056.n5IKumjR015978@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 15:56:48 2009 New Revision: 73723 URL: http://llvm.org/viewvc/llvm-project?rev=73723&view=rev Log: Simplify. 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=73723&r1=73722&r2=73723&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Thu Jun 18 15:56:48 2009 @@ -233,37 +233,30 @@ // use GC. static DenseMap *GCNames; static StringPool *GCNamePool; -static ManagedStatic GCLock; +static ManagedStatic > GCLock; bool Function::hasGC() const { - if (llvm_is_multithreaded()) { - sys::ScopedReader Reader(&*GCLock); - return GCNames && GCNames->count(this); - } else - return GCNames && GCNames->count(this); + sys::SmartScopedReader Reader(&*GCLock); + return GCNames && GCNames->count(this); } const char *Function::getGC() const { assert(hasGC() && "Function has no collector"); - if (llvm_is_multithreaded()) { - sys::ScopedReader Reader(&*GCLock); - return *(*GCNames)[this]; - } else - return *(*GCNames)[this]; + sys::SmartScopedReader Reader(&*GCLock); + return *(*GCNames)[this]; } void Function::setGC(const char *Str) { - if (llvm_is_multithreaded()) GCLock->writer_acquire(); + sys::SmartScopedWriter Writer(&*GCLock); if (!GCNamePool) GCNamePool = new StringPool(); if (!GCNames) GCNames = new DenseMap(); (*GCNames)[this] = GCNamePool->intern(Str); - if (llvm_is_multithreaded()) GCLock->writer_release(); } void Function::clearGC() { - if (llvm_is_multithreaded()) GCLock->writer_acquire(); + sys::SmartScopedWriter Writer(&*GCLock); if (GCNames) { GCNames->erase(this); if (GCNames->empty()) { @@ -275,7 +268,6 @@ } } } - if (llvm_is_multithreaded()) GCLock->writer_release(); } /// copyAttributesFrom - copy all additional attributes (those not needed to From mai4 at uiuc.edu Thu Jun 18 16:15:00 2009 From: mai4 at uiuc.edu (Haohui Mai) Date: Thu, 18 Jun 2009 21:15:00 -0000 Subject: [llvm-commits] [poolalloc] r73724 - in /poolalloc/trunk: include/poolalloc/PoolAllocate.h lib/PoolAllocate/PASimple.cpp Message-ID: <200906182115.n5ILF0Xj016681@zion.cs.uiuc.edu> Author: mai4 Date: Thu Jun 18 16:15:00 2009 New Revision: 73724 URL: http://llvm.org/viewvc/llvm-project?rev=73724&view=rev Log: Enlarge the size of pool descriptor to match the update with SAFECode. Also make the global pool descriptor visible to SAFECode by changing the linking to ExternalLinkage. Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=73724&r1=73723&r2=73724&view=diff ============================================================================== --- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original) +++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Thu Jun 18 16:15:00 2009 @@ -238,7 +238,7 @@ const Type * getPoolType() { Type * VoidPtrType = PointerType::getUnqual(Type::Int8Ty); if (SAFECodeEnabled) - return ArrayType::get(VoidPtrType, 50); + return ArrayType::get(VoidPtrType, 92); else return ArrayType::get(VoidPtrType, 16); } Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=73724&r1=73723&r2=73724&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Thu Jun 18 16:15:00 2009 @@ -353,8 +353,8 @@ unsigned Align, Module& M) { GlobalVariable *GV = - new GlobalVariable(getPoolType(), false, GlobalValue::InternalLinkage, - Constant::getNullValue(getPoolType()), "poolalloc.GlobalPool", + new GlobalVariable(getPoolType(), false, GlobalValue::ExternalLinkage, + Constant::getNullValue(getPoolType()), "__poolalloc_GlobalPool", &M); Function *InitFunc = Function::Create From resistor at mac.com Thu Jun 18 16:35:56 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 21:35:56 -0000 Subject: [llvm-commits] [llvm] r73725 - /llvm/trunk/lib/VMCore/LeakDetector.cpp Message-ID: <200906182135.n5ILZuLW017916@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 16:35:56 2009 New Revision: 73725 URL: http://llvm.org/viewvc/llvm-project?rev=73725&view=rev Log: Simplify. Modified: llvm/trunk/lib/VMCore/LeakDetector.cpp Modified: llvm/trunk/lib/VMCore/LeakDetector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LeakDetector.cpp?rev=73725&r1=73724&r2=73725&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LeakDetector.cpp (original) +++ llvm/trunk/lib/VMCore/LeakDetector.cpp Thu Jun 18 16:35:56 2009 @@ -32,7 +32,7 @@ static void print(const Value* P) { cerr << *P; } }; - ManagedStatic LeakDetectorLock; + ManagedStatic > LeakDetectorLock; template struct VISIBILITY_HIDDEN LeakDetectorImpl { @@ -54,41 +54,26 @@ // immediately, it is added to the CachedValue Value. If it is // immediately removed, no set search need be performed. void addGarbage(const T* o) { - if (llvm_is_multithreaded()) { - sys::ScopedWriter Writer(&*LeakDetectorLock); - if (Cache) { - assert(Ts.count(Cache) == 0 && "Object already in set!"); - Ts.insert(Cache); - } - Cache = o; - } else { - if (Cache) { - assert(Ts.count(Cache) == 0 && "Object already in set!"); - Ts.insert(Cache); - } - Cache = o; + sys::SmartScopedWriter Writer(&*LeakDetectorLock); + if (Cache) { + assert(Ts.count(Cache) == 0 && "Object already in set!"); + Ts.insert(Cache); } + Cache = o; } void removeGarbage(const T* o) { - if (llvm_is_multithreaded()) { - sys::ScopedWriter Writer(&*LeakDetectorLock); - if (o == Cache) - Cache = 0; // Cache hit - else - Ts.erase(o); - } else { - if (o == Cache) - Cache = 0; // Cache hit - else - Ts.erase(o); - } + sys::SmartScopedWriter Writer(&*LeakDetectorLock); + if (o == Cache) + Cache = 0; // Cache hit + else + Ts.erase(o); } bool hasGarbage(const std::string& Message) { addGarbage(0); // Flush the Cache - if (llvm_is_multithreaded()) LeakDetectorLock->reader_acquire(); + sys::SmartScopedReader Reader(&*LeakDetectorLock); assert(Cache == 0 && "No value should be cached anymore!"); if (!Ts.empty()) { @@ -101,11 +86,9 @@ } cerr << '\n'; - if (llvm_is_multithreaded()) LeakDetectorLock->reader_release(); return true; } - if (llvm_is_multithreaded()) LeakDetectorLock->reader_release(); return false; } From evan.cheng at apple.com Thu Jun 18 16:39:50 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 18 Jun 2009 21:39:50 -0000 Subject: [llvm-commits] [llvm] r73726 - /llvm/trunk/utils/NewNightlyTest.pl Message-ID: <200906182139.n5ILdoGV018051@zion.cs.uiuc.edu> Author: evancheng Date: Thu Jun 18 16:39:50 2009 New Revision: 73726 URL: http://llvm.org/viewvc/llvm-project?rev=73726&view=rev Log: Allow user to specify separate SVN url for llvm and the test suite. Modified: llvm/trunk/utils/NewNightlyTest.pl Modified: llvm/trunk/utils/NewNightlyTest.pl URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/NewNightlyTest.pl?rev=73726&r1=73725&r2=73726&view=diff ============================================================================== --- llvm/trunk/utils/NewNightlyTest.pl (original) +++ llvm/trunk/utils/NewNightlyTest.pl Thu Jun 18 16:39:50 2009 @@ -99,6 +99,8 @@ my $HOME = $ENV{'HOME'}; my $SVNURL = $ENV{"SVNURL"}; $SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL; +my $TestSVNURL = $ENV{"TestSVNURL"}; +$TestSVNURL = 'https://llvm.org/svn/llvm-project' unless $TestSVNURL; my $CVSRootDir = $ENV{'CVSROOT'}; $CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir; my $BuildDir = $ENV{'BUILDDIR'}; @@ -537,19 +539,20 @@ if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; } if ($USESVN) { my $SVNCMD = "$NICE svn co --non-interactive $SVNURL"; + my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL"; if ($VERBOSE) { print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " . - "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n"; + "$SVNCMD2/test-suite/trunk llvm-test ) > $COLog 2>&1\n"; } system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " . - "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n"; - if ($WITHCLANG) { - my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk"; - if ($VERBOSE) { - print "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n"; - } - system "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n"; - } + "$SVNCMD2/test-suite/trunk llvm-test ) > $COLog 2>&1\n"; + if ($WITHCLANG) { + my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk"; + if ($VERBOSE) { + print "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n"; + } + system "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n"; + } } else { my $CVSOPT = ""; $CVSOPT = "-z3" # Use compression if going over ssh. From lhames at gmail.com Thu Jun 18 17:01:47 2009 From: lhames at gmail.com (Lang Hames) Date: Thu, 18 Jun 2009 22:01:47 -0000 Subject: [llvm-commits] [llvm] r73727 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200906182201.n5IM1lxG019142@zion.cs.uiuc.edu> Author: lhames Date: Thu Jun 18 17:01:47 2009 New Revision: 73727 URL: http://llvm.org/viewvc/llvm-project?rev=73727&view=rev Log: Improved PHI def marking, replaced some gotos with breaks. 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=73727&r1=73726&r2=73727&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Jun 18 17:01:47 2009 @@ -584,7 +584,7 @@ // Replace the interval with one of a NEW value number. Note that this // value number isn't actually defined by an instruction, weird huh? :) - LiveRange LR(Start, End, interval.getNextValue(0, 0, false, VNInfoAllocator)); + LiveRange LR(Start, End, interval.getNextValue(Start, 0, false, VNInfoAllocator)); LR.valno->setIsPHIDef(true); DOUT << " replace range with " << LR; interval.addRange(LR); @@ -753,7 +753,7 @@ DOUT << " killed"; end = getUseIndex(baseIndex) + 1; SeenDefUse = true; - goto exit; + break; } else if (mi->modifiesRegister(interval.reg, tri_)) { // Another instruction redefines the register before it is ever read. // Then the register is essentially dead at the instruction that defines @@ -762,7 +762,7 @@ DOUT << " dead"; end = getDefIndex(start) + 1; SeenDefUse = true; - goto exit; + break; } baseIndex += InstrSlots::NUM; @@ -774,7 +774,6 @@ } } -exit: // Live-in register might not be used at all. if (!SeenDefUse) { if (isAlias) { @@ -786,7 +785,10 @@ } } - LiveRange LR(start, end, interval.getNextValue(0, 0, false, VNInfoAllocator)); + VNInfo *vni = interval.getNextValue(start, 0, false, VNInfoAllocator); + vni->setIsPHIDef(true); + LiveRange LR(start, end, vni); + interval.addRange(LR); interval.addKill(LR.valno, end); DOUT << " +" << LR << '\n'; From resistor at mac.com Thu Jun 18 17:25:21 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 18 Jun 2009 22:25:21 -0000 Subject: [llvm-commits] [llvm] r73728 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h include/llvm/Analysis/ScalarEvolutionExpressions.h lib/Analysis/ScalarEvolution.cpp Message-ID: <200906182225.n5IMPNo4019977@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 17:25:12 2009 New Revision: 73728 URL: http://llvm.org/viewvc/llvm-project?rev=73728&view=rev Log: Add a parent pointer to SCEV, in preparation for getting rid of the global uniquing tables. No functionality change. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=73728&r1=73727&r2=73728&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Thu Jun 18 17:25:12 2009 @@ -53,12 +53,15 @@ delete this; } + const ScalarEvolution* parent; + SCEV(const SCEV &); // DO NOT IMPLEMENT void operator=(const SCEV &); // DO NOT IMPLEMENT protected: virtual ~SCEV(); public: - explicit SCEV(unsigned SCEVTy) : SCEVType(SCEVTy), RefCount(0) {} + explicit SCEV(unsigned SCEVTy, const ScalarEvolution* p) : + SCEVType(SCEVTy), RefCount(0), parent(p) {} unsigned getSCEVType() const { return SCEVType; } @@ -126,7 +129,7 @@ /// None of the standard SCEV operations are valid on this class, it is just a /// marker. struct SCEVCouldNotCompute : public SCEV { - SCEVCouldNotCompute(); + SCEVCouldNotCompute(const ScalarEvolution* p); ~SCEVCouldNotCompute(); // None of these methods are valid for this object. @@ -205,13 +208,13 @@ template<> struct DenseMapInfo { static inline SCEVHandle getEmptyKey() { - static SCEVCouldNotCompute Empty; + static SCEVCouldNotCompute Empty(0); if (Empty.RefCount == 0) Empty.addRef(); return &Empty; } static inline SCEVHandle getTombstoneKey() { - static SCEVCouldNotCompute Tombstone; + static SCEVCouldNotCompute Tombstone(0); if (Tombstone.RefCount == 0) Tombstone.addRef(); return &Tombstone; Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h?rev=73728&r1=73727&r2=73728&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Thu Jun 18 17:25:12 2009 @@ -36,7 +36,8 @@ friend class ScalarEvolution; ConstantInt *V; - explicit SCEVConstant(ConstantInt *v) : SCEV(scConstant), V(v) {} + explicit SCEVConstant(ConstantInt *v, const ScalarEvolution* p) : + SCEV(scConstant, p), V(v) {} virtual ~SCEVConstant(); public: @@ -79,7 +80,8 @@ SCEVHandle Op; const Type *Ty; - SCEVCastExpr(unsigned SCEVTy, const SCEVHandle &op, const Type *ty); + SCEVCastExpr(unsigned SCEVTy, const SCEVHandle &op, const Type *ty, + const ScalarEvolution* p); virtual ~SCEVCastExpr(); public: @@ -112,7 +114,8 @@ class SCEVTruncateExpr : public SCEVCastExpr { friend class ScalarEvolution; - SCEVTruncateExpr(const SCEVHandle &op, const Type *ty); + SCEVTruncateExpr(const SCEVHandle &op, const Type *ty, + const ScalarEvolution* p); virtual ~SCEVTruncateExpr(); public: @@ -141,7 +144,8 @@ class SCEVZeroExtendExpr : public SCEVCastExpr { friend class ScalarEvolution; - SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty); + SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty, + const ScalarEvolution* p); virtual ~SCEVZeroExtendExpr(); public: @@ -170,7 +174,8 @@ class SCEVSignExtendExpr : public SCEVCastExpr { friend class ScalarEvolution; - SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty); + SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty, + const ScalarEvolution* p); virtual ~SCEVSignExtendExpr(); public: @@ -201,8 +206,9 @@ protected: SmallVector Operands; - SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl &ops) - : SCEV(T), Operands(ops.begin(), ops.end()) {} + SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl &ops, + const ScalarEvolution* p) + : SCEV(T, p), Operands(ops.begin(), ops.end()) {} virtual ~SCEVNAryExpr() {} public: @@ -259,8 +265,10 @@ /// class SCEVCommutativeExpr : public SCEVNAryExpr { protected: - SCEVCommutativeExpr(enum SCEVTypes T, const SmallVectorImpl &ops) - : SCEVNAryExpr(T, ops) {} + SCEVCommutativeExpr(enum SCEVTypes T, + const SmallVectorImpl &ops, + const ScalarEvolution* p) + : SCEVNAryExpr(T, ops, p) {} ~SCEVCommutativeExpr(); public: @@ -289,8 +297,9 @@ class SCEVAddExpr : public SCEVCommutativeExpr { friend class ScalarEvolution; - explicit SCEVAddExpr(const SmallVectorImpl &ops) - : SCEVCommutativeExpr(scAddExpr, ops) { + explicit SCEVAddExpr(const SmallVectorImpl &ops, + const ScalarEvolution* p) + : SCEVCommutativeExpr(scAddExpr, ops, p) { } public: @@ -309,8 +318,9 @@ class SCEVMulExpr : public SCEVCommutativeExpr { friend class ScalarEvolution; - explicit SCEVMulExpr(const SmallVectorImpl &ops) - : SCEVCommutativeExpr(scMulExpr, ops) { + explicit SCEVMulExpr(const SmallVectorImpl &ops, + const ScalarEvolution* p) + : SCEVCommutativeExpr(scMulExpr, ops, p) { } public: @@ -331,8 +341,9 @@ friend class ScalarEvolution; SCEVHandle LHS, RHS; - SCEVUDivExpr(const SCEVHandle &lhs, const SCEVHandle &rhs) - : SCEV(scUDivExpr), LHS(lhs), RHS(rhs) {} + SCEVUDivExpr(const SCEVHandle &lhs, const SCEVHandle &rhs, + const ScalarEvolution* p) + : SCEV(scUDivExpr, p), LHS(lhs), RHS(rhs) {} virtual ~SCEVUDivExpr(); public: @@ -387,8 +398,9 @@ const Loop *L; - SCEVAddRecExpr(const SmallVectorImpl &ops, const Loop *l) - : SCEVNAryExpr(scAddRecExpr, ops), L(l) { + SCEVAddRecExpr(const SmallVectorImpl &ops, const Loop *l, + const ScalarEvolution* p) + : SCEVNAryExpr(scAddRecExpr, ops, p), L(l) { for (size_t i = 0, e = Operands.size(); i != e; ++i) assert(Operands[i]->isLoopInvariant(l) && "Operands of AddRec must be loop-invariant!"); @@ -463,8 +475,9 @@ class SCEVSMaxExpr : public SCEVCommutativeExpr { friend class ScalarEvolution; - explicit SCEVSMaxExpr(const SmallVectorImpl &ops) - : SCEVCommutativeExpr(scSMaxExpr, ops) { + explicit SCEVSMaxExpr(const SmallVectorImpl &ops, + const ScalarEvolution* p) + : SCEVCommutativeExpr(scSMaxExpr, ops, p) { } public: @@ -484,8 +497,9 @@ class SCEVUMaxExpr : public SCEVCommutativeExpr { friend class ScalarEvolution; - explicit SCEVUMaxExpr(const SmallVectorImpl &ops) - : SCEVCommutativeExpr(scUMaxExpr, ops) { + explicit SCEVUMaxExpr(const SmallVectorImpl &ops, + const ScalarEvolution* p) + : SCEVCommutativeExpr(scUMaxExpr, ops, p) { } public: @@ -508,7 +522,8 @@ friend class ScalarEvolution; Value *V; - explicit SCEVUnknown(Value *v) : SCEV(scUnknown), V(v) {} + explicit SCEVUnknown(Value *v, const ScalarEvolution* p) : + SCEV(scUnknown, p), V(v) {} protected: ~SCEVUnknown(); Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=73728&r1=73727&r2=73728&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Jun 18 17:25:12 2009 @@ -133,7 +133,8 @@ return false; } -SCEVCouldNotCompute::SCEVCouldNotCompute() : SCEV(scCouldNotCompute) {} +SCEVCouldNotCompute::SCEVCouldNotCompute(const ScalarEvolution* p) : + SCEV(scCouldNotCompute, p) {} SCEVCouldNotCompute::~SCEVCouldNotCompute() {} bool SCEVCouldNotCompute::isLoopInvariant(const Loop *L) const { @@ -179,7 +180,7 @@ SCEVHandle ScalarEvolution::getConstant(ConstantInt *V) { SCEVConstant *&R = (*SCEVConstants)[V]; - if (R == 0) R = new SCEVConstant(V); + if (R == 0) R = new SCEVConstant(V, this); return R; } @@ -199,8 +200,9 @@ } SCEVCastExpr::SCEVCastExpr(unsigned SCEVTy, - const SCEVHandle &op, const Type *ty) - : SCEV(SCEVTy), Op(op), Ty(ty) {} + const SCEVHandle &op, const Type *ty, + const ScalarEvolution* p) + : SCEV(SCEVTy, p), Op(op), Ty(ty) {} SCEVCastExpr::~SCEVCastExpr() {} @@ -214,8 +216,9 @@ static ManagedStatic, SCEVTruncateExpr*> > SCEVTruncates; -SCEVTruncateExpr::SCEVTruncateExpr(const SCEVHandle &op, const Type *ty) - : SCEVCastExpr(scTruncate, op, ty) { +SCEVTruncateExpr::SCEVTruncateExpr(const SCEVHandle &op, const Type *ty, + const ScalarEvolution* p) + : SCEVCastExpr(scTruncate, op, ty, p) { assert((Op->getType()->isInteger() || isa(Op->getType())) && (Ty->isInteger() || isa(Ty)) && "Cannot truncate non-integer value!"); @@ -235,8 +238,9 @@ static ManagedStatic, SCEVZeroExtendExpr*> > SCEVZeroExtends; -SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty) - : SCEVCastExpr(scZeroExtend, op, ty) { +SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty, + const ScalarEvolution* p) + : SCEVCastExpr(scZeroExtend, op, ty, p) { assert((Op->getType()->isInteger() || isa(Op->getType())) && (Ty->isInteger() || isa(Ty)) && "Cannot zero extend non-integer value!"); @@ -256,8 +260,9 @@ static ManagedStatic, SCEVSignExtendExpr*> > SCEVSignExtends; -SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty) - : SCEVCastExpr(scSignExtend, op, ty) { +SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty, + const ScalarEvolution* p) + : SCEVCastExpr(scSignExtend, op, ty, p) { assert((Op->getType()->isInteger() || isa(Op->getType())) && (Ty->isInteger() || isa(Ty)) && "Cannot sign extend non-integer value!"); @@ -787,7 +792,7 @@ } SCEVTruncateExpr *&Result = (*SCEVTruncates)[std::make_pair(Op, Ty)]; - if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty); + if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty, this); return Result; } @@ -875,7 +880,7 @@ } SCEVZeroExtendExpr *&Result = (*SCEVZeroExtends)[std::make_pair(Op, Ty)]; - if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty); + if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty, this); return Result; } @@ -947,7 +952,7 @@ } SCEVSignExtendExpr *&Result = (*SCEVSignExtends)[std::make_pair(Op, Ty)]; - if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty); + if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty, this); return Result; } @@ -1409,7 +1414,7 @@ std::vector SCEVOps(Ops.begin(), Ops.end()); SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scAddExpr, SCEVOps)]; - if (Result == 0) Result = new SCEVAddExpr(Ops); + if (Result == 0) Result = new SCEVAddExpr(Ops, this); return Result; } @@ -1575,7 +1580,7 @@ SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scMulExpr, SCEVOps)]; if (Result == 0) - Result = new SCEVMulExpr(Ops); + Result = new SCEVMulExpr(Ops, this); return Result; } @@ -1666,7 +1671,7 @@ } SCEVUDivExpr *&Result = (*SCEVUDivs)[std::make_pair(LHS, RHS)]; - if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS); + if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS, this); return Result; } @@ -1720,7 +1725,7 @@ std::vector SCEVOps(Operands.begin(), Operands.end()); SCEVAddRecExpr *&Result = (*SCEVAddRecExprs)[std::make_pair(L, SCEVOps)]; - if (Result == 0) Result = new SCEVAddRecExpr(Operands, L); + if (Result == 0) Result = new SCEVAddRecExpr(Operands, L, this); return Result; } @@ -1807,7 +1812,7 @@ std::vector SCEVOps(Ops.begin(), Ops.end()); SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scSMaxExpr, SCEVOps)]; - if (Result == 0) Result = new SCEVSMaxExpr(Ops); + if (Result == 0) Result = new SCEVSMaxExpr(Ops, this); return Result; } @@ -1894,7 +1899,7 @@ std::vector SCEVOps(Ops.begin(), Ops.end()); SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scUMaxExpr, SCEVOps)]; - if (Result == 0) Result = new SCEVUMaxExpr(Ops); + if (Result == 0) Result = new SCEVUMaxExpr(Ops, this); return Result; } @@ -1904,7 +1909,7 @@ if (isa(V)) return getIntegerSCEV(0, V->getType()); SCEVUnknown *&Result = (*SCEVUnknowns)[V]; - if (Result == 0) Result = new SCEVUnknown(V); + if (Result == 0) Result = new SCEVUnknown(V, this); return Result; } @@ -3978,7 +3983,7 @@ //===----------------------------------------------------------------------===// ScalarEvolution::ScalarEvolution() - : FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute()) { + : FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute(0)) { } bool ScalarEvolution::runOnFunction(Function &F) { From evan.cheng at apple.com Thu Jun 18 17:35:39 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 18 Jun 2009 15:35:39 -0700 Subject: [llvm-commits] [llvm] r73727 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp In-Reply-To: <200906182201.n5IM1lxG019142@zion.cs.uiuc.edu> References: <200906182201.n5IM1lxG019142@zion.cs.uiuc.edu> Message-ID: On Jun 18, 2009, at 3:01 PM, Lang Hames wrote: > Author: lhames > Date: Thu Jun 18 17:01:47 2009 > New Revision: 73727 > > URL: http://llvm.org/viewvc/llvm-project?rev=73727&view=rev > Log: > Improved PHI def marking, replaced some gotos with breaks. > > 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=73727&r1=73726&r2=73727&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) > +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Jun 18 > 17:01:47 2009 > @@ -584,7 +584,7 @@ > > // Replace the interval with one of a NEW value number. > Note that this > // value number isn't actually defined by an instruction, > weird huh? :) Please clarify the comment. VN# defined by a phi has imprecise def number that points to the start of the BB? Evan > - LiveRange LR(Start, End, interval.getNextValue(0, 0, false, > VNInfoAllocator)); > + LiveRange LR(Start, End, interval.getNextValue(Start, 0, > false, VNInfoAllocator)); > LR.valno->setIsPHIDef(true); > DOUT << " replace range with " << LR; > interval.addRange(LR); > @@ -753,7 +753,7 @@ > DOUT << " killed"; > end = getUseIndex(baseIndex) + 1; > SeenDefUse = true; > - goto exit; > + break; > } else if (mi->modifiesRegister(interval.reg, tri_)) { > // Another instruction redefines the register before it is > ever read. > // Then the register is essentially dead at the instruction > that defines > @@ -762,7 +762,7 @@ > DOUT << " dead"; > end = getDefIndex(start) + 1; > SeenDefUse = true; > - goto exit; > + break; > } > > baseIndex += InstrSlots::NUM; > @@ -774,7 +774,6 @@ > } > } > > -exit: > // Live-in register might not be used at all. > if (!SeenDefUse) { > if (isAlias) { > @@ -786,7 +785,10 @@ > } > } > > - LiveRange LR(start, end, interval.getNextValue(0, 0, false, > VNInfoAllocator)); > + VNInfo *vni = interval.getNextValue(start, 0, false, > VNInfoAllocator); > + vni->setIsPHIDef(true); > + LiveRange LR(start, end, vni); > + > interval.addRange(LR); > interval.addKill(LR.valno, end); > DOUT << " +" << LR << '\n'; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Thu Jun 18 17:53:31 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Jun 2009 22:53:31 -0000 Subject: [llvm-commits] [llvm] r73729 - /llvm/trunk/test/FrontendC/2009-06-18-StaticInitTailPadPack.c Message-ID: <200906182253.n5IMrVZI021807@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 17:53:26 2009 New Revision: 73729 URL: http://llvm.org/viewvc/llvm-project?rev=73729&view=rev Log: new testcase for rdar://6983634 Added: llvm/trunk/test/FrontendC/2009-06-18-StaticInitTailPadPack.c Added: llvm/trunk/test/FrontendC/2009-06-18-StaticInitTailPadPack.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2009-06-18-StaticInitTailPadPack.c?rev=73729&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/2009-06-18-StaticInitTailPadPack.c (added) +++ llvm/trunk/test/FrontendC/2009-06-18-StaticInitTailPadPack.c Thu Jun 18 17:53:26 2009 @@ -0,0 +1,26 @@ +// RUN: %llvmgcc %s -S -o - +// rdar://6983634 + + typedef struct A *Foo; +#pragma pack(push, 2) + struct Bar { + Foo f1; + unsigned short f2; + float f3; + }; + struct Baz { + struct Bar f1; + struct Bar f2; + }; + struct Qux { + unsigned long f1; + struct Baz f2; + }; +extern const struct Qux Bork; +const struct Qux Bork = { + 0, + { + {0}, + {0} + } +}; From sabre at nondot.org Thu Jun 18 17:54:19 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Jun 2009 22:54:19 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r73730 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200906182254.n5IMsKCl021871@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 17:54:19 2009 New Revision: 73730 URL: http://llvm.org/viewvc/llvm-project?rev=73730&view=rev Log: fix rdar://6983634 - when inserting tail padding to round up an initializer to the right size, we have to be careful when the max struct alignment will cause the size-with-alignment to be too big. In this case, switch the struct to being packed. This fixes rdar://6983634 and test/FrontendC/2009-06-18-StaticInitTailPadPack.c 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=73730&r1=73729&r2=73730&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Jun 18 17:54:19 2009 @@ -7187,6 +7187,21 @@ if (GCCStructSize - NextFieldByteStart != 1) FillTy = ArrayType::get(FillTy, GCCStructSize - NextFieldByteStart); ResultElts.push_back(Constant::getNullValue(FillTy)); + NextFieldByteStart = GCCStructSize; + + // At this point, we know that our struct should have the right size. + // However, if the size of the struct is not a multiple of the largest + // element alignment, the rounding could bump up the struct more. In this + // case, we have to convert the struct to being packed. + LLVMNaturalSize = + TargetData::RoundUpAlignment(NextFieldByteStart, MaxLLVMFieldAlignment); + + // If the alignment will make the struct too big, convert it to being + // packed. + if (LLVMNaturalSize > GCCStructSize) { + assert(!StructIsPacked && "LLVM Struct type overflow!"); + ConvertToPacked(); + } } } From sabre at nondot.org Thu Jun 18 18:04:49 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Jun 2009 23:04:49 -0000 Subject: [llvm-commits] [llvm] r73732 - in /llvm/trunk/tools: CMakeLists.txt Makefile llvm-mc/ llvm-mc/CMakeLists.txt llvm-mc/Makefile llvm-mc/llvm-mc.cpp Message-ID: <200906182304.n5IN4nUK022570@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 18:04:45 2009 New Revision: 73732 URL: http://llvm.org/viewvc/llvm-project?rev=73732&view=rev Log: Add a skeleton driver for new machine code level fun. llvm-mc is meant to be a test driver of other components in the system, which will develop over time. Added: llvm/trunk/tools/llvm-mc/ llvm/trunk/tools/llvm-mc/CMakeLists.txt llvm/trunk/tools/llvm-mc/Makefile llvm/trunk/tools/llvm-mc/llvm-mc.cpp Modified: llvm/trunk/tools/CMakeLists.txt llvm/trunk/tools/Makefile Modified: llvm/trunk/tools/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/CMakeLists.txt?rev=73732&r1=73731&r2=73732&view=diff ============================================================================== --- llvm/trunk/tools/CMakeLists.txt (original) +++ llvm/trunk/tools/CMakeLists.txt Thu Jun 18 18:04:45 2009 @@ -9,6 +9,7 @@ add_subdirectory(opt) add_subdirectory(llvm-as) add_subdirectory(llvm-dis) +add_subdirectory(llvm-mc) add_subdirectory(llc) add_subdirectory(llvm-ranlib) Modified: llvm/trunk/tools/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/Makefile?rev=73732&r1=73731&r2=73732&view=diff ============================================================================== --- llvm/trunk/tools/Makefile (original) +++ llvm/trunk/tools/Makefile Thu Jun 18 18:04:45 2009 @@ -20,7 +20,8 @@ llc llvm-ranlib llvm-ar llvm-nm \ llvm-ld llvm-prof llvm-link \ lli gccas gccld llvm-extract llvm-db \ - bugpoint llvm-bcanalyzer llvm-stub llvmc + bugpoint llvm-bcanalyzer llvm-stub llvmc \ + llvm-mc # Let users override the set of tools to build from the command line. ifdef ONLY_TOOLS Added: llvm/trunk/tools/llvm-mc/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/CMakeLists.txt?rev=73732&view=auto ============================================================================== --- llvm/trunk/tools/llvm-mc/CMakeLists.txt (added) +++ llvm/trunk/tools/llvm-mc/CMakeLists.txt Thu Jun 18 18:04:45 2009 @@ -0,0 +1,5 @@ +set(LLVM_LINK_COMPONENTS support) + +add_llvm_tool(llvm-dis + llvm-mc.cpp + ) Added: llvm/trunk/tools/llvm-mc/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/Makefile?rev=73732&view=auto ============================================================================== --- llvm/trunk/tools/llvm-mc/Makefile (added) +++ llvm/trunk/tools/llvm-mc/Makefile Thu Jun 18 18:04:45 2009 @@ -0,0 +1,17 @@ +##===- tools/llvm-mc/Makefile ------------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../.. +TOOLNAME = llvm-mc +LINK_COMPONENTS := support + +# This tool has no plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +include $(LEVEL)/Makefile.common Added: llvm/trunk/tools/llvm-mc/llvm-mc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=73732&view=auto ============================================================================== --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (added) +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Thu Jun 18 18:04:45 2009 @@ -0,0 +1,61 @@ +//===-- llvm-dis.cpp - The low-level LLVM disassembler --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This utility may be invoked in the following manner: +// llvm-dis [options] - Read LLVM bitcode from stdin, write asm to stdout +// llvm-dis [options] x.bc - Read LLVM bitcode from the x.bc file, write asm +// to the x.ll file. +// Options: +// --help - Output information about command line switches +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/System/Signals.h" +using namespace llvm; + +static cl::opt +InputFilename(cl::Positional, cl::desc(""), cl::init("-")); + +static cl::opt +OutputFilename("o", cl::desc("Output filename"), + cl::value_desc("filename")); + +int main(int argc, char **argv) { + // Print a stack trace if we signal out. + sys::PrintStackTraceOnErrorSignal(); + PrettyStackTraceProgram X(argc, argv); + + llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. + + cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n"); + + std::string ErrorMessage; + + MemoryBuffer *Buffer + = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage); + + if (Buffer == 0) { + errs() << argv[0] << ": "; + if (ErrorMessage.size()) + errs() << ErrorMessage << "\n"; + else + errs() << "input file didn't read correctly.\n"; + return 1; + } + + + + return 0; +} + From sabre at nondot.org Thu Jun 18 18:05:22 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Jun 2009 23:05:22 -0000 Subject: [llvm-commits] [llvm] r73733 - /llvm/trunk/tools/llvm-mc/llvm-mc.cpp Message-ID: <200906182305.n5IN5Mgi022612@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 18:05:21 2009 New Revision: 73733 URL: http://llvm.org/viewvc/llvm-project?rev=73733&view=rev Log: fix file header Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp 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=73733&r1=73732&r2=73733&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original) +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Thu Jun 18 18:05:21 2009 @@ -1,4 +1,4 @@ -//===-- llvm-dis.cpp - The low-level LLVM disassembler --------------------===// +//===-- llvm-mc.cpp - Machine Code Hacking Driver -------------------------===// // // The LLVM Compiler Infrastructure // @@ -7,12 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This utility may be invoked in the following manner: -// llvm-dis [options] - Read LLVM bitcode from stdin, write asm to stdout -// llvm-dis [options] x.bc - Read LLVM bitcode from the x.bc file, write asm -// to the x.ll file. -// Options: -// --help - Output information about command line switches +// This utility is a simple driver that allows command line hacking on machine +// code. // //===----------------------------------------------------------------------===// From evan.cheng at apple.com Thu Jun 18 18:14:30 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 18 Jun 2009 23:14:30 -0000 Subject: [llvm-commits] [llvm] r73734 - in /llvm/trunk/lib/Target/ARM: ARMISelLowering.cpp ARMRegisterInfo.cpp ARMRegisterInfo.td ARMSubtarget.cpp ARMSubtarget.h Message-ID: <200906182314.n5INEVwJ023213@zion.cs.uiuc.edu> Author: evancheng Date: Thu Jun 18 18:14:30 2009 New Revision: 73734 URL: http://llvm.org/viewvc/llvm-project?rev=73734&view=rev Log: Remove UseThumbBacktraces. Just check if subtarget is darwin. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=73734&r1=73733&r2=73734&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Jun 18 18:14:30 2009 @@ -1483,7 +1483,7 @@ MVT VT = Op.getValueType(); DebugLoc dl = Op.getDebugLoc(); // FIXME probably not meaningful unsigned Depth = cast(Op.getOperand(0))->getZExtValue(); - unsigned FrameReg = (Subtarget->isThumb() || Subtarget->useThumbBacktraces()) + unsigned FrameReg = (Subtarget->isThumb() || Subtarget->isTargetDarwin()) ? ARM::R7 : ARM::R11; SDValue FrameAddr = DAG.getCopyFromReg(DAG.getEntryNode(), dl, FrameReg, VT); while (Depth--) Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp?rev=73734&r1=73733&r2=73734&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.cpp Thu Jun 18 18:14:30 2009 @@ -159,7 +159,7 @@ const ARMSubtarget &sti) : ARMGenRegisterInfo(ARM::ADJCALLSTACKDOWN, ARM::ADJCALLSTACKUP), TII(tii), STI(sti), - FramePtr((STI.useThumbBacktraces() || STI.isThumb()) ? ARM::R7 : ARM::R11) { + FramePtr((STI.isTargetDarwin() || STI.isThumb()) ? ARM::R7 : ARM::R11) { } static inline @@ -1687,9 +1687,8 @@ unsigned ARMRegisterInfo::getFrameRegister(MachineFunction &MF) const { if (STI.isTargetDarwin() || hasFP(MF)) - return (STI.useThumbBacktraces() || STI.isThumb()) ? ARM::R7 : ARM::R11; - else - return ARM::SP; + return FramePtr; + return ARM::SP; } unsigned ARMRegisterInfo::getEHExceptionRegister() const { Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td?rev=73734&r1=73733&r2=73734&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Thu Jun 18 18:14:30 2009 @@ -134,7 +134,7 @@ GPRClass::allocation_order_begin(const MachineFunction &MF) const { const TargetMachine &TM = MF.getTarget(); const ARMSubtarget &Subtarget = TM.getSubtarget(); - if (Subtarget.useThumbBacktraces()) { + if (Subtarget.isTargetDarwin()) { if (Subtarget.isR9Reserved()) return ARM_GPR_AO_4; else @@ -154,7 +154,7 @@ const ARMSubtarget &Subtarget = TM.getSubtarget(); GPRClass::iterator I; - if (Subtarget.useThumbBacktraces()) { + if (Subtarget.isTargetDarwin()) { if (Subtarget.isR9Reserved()) { I = ARM_GPR_AO_4 + (sizeof(ARM_GPR_AO_4)/sizeof(unsigned)); } else { Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=73734&r1=73733&r2=73734&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Thu Jun 18 18:14:30 2009 @@ -24,7 +24,6 @@ , ARMFPUType(None) , IsThumb(isThumb) , ThumbMode(Thumb1) - , UseThumbBacktraces(false) , IsR9Reserved(false) , stackAlignment(4) , CPUString("generic") @@ -83,8 +82,6 @@ if (isAAPCS_ABI()) stackAlignment = 8; - if (isTargetDarwin()) { - UseThumbBacktraces = true; + if (isTargetDarwin()) IsR9Reserved = true; - } } Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=73734&r1=73733&r2=73734&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Thu Jun 18 18:14:30 2009 @@ -48,9 +48,6 @@ /// ThumbMode - Indicates supported Thumb version. ThumbTypeEnum ThumbMode; - /// UseThumbBacktraces - True if we use thumb style backtraces. - bool UseThumbBacktraces; - /// IsR9Reserved - True if R9 is a not available as general purpose register. bool IsR9Reserved; @@ -109,7 +106,6 @@ bool isThumb1Only() const { return IsThumb && (ThumbMode == Thumb1); } bool hasThumb2() const { return IsThumb && (ThumbMode >= Thumb2); } - bool useThumbBacktraces() const { return UseThumbBacktraces; } bool isR9Reserved() const { return IsR9Reserved; } const std::string & getCPUString() const { return CPUString; } From sabre at nondot.org Thu Jun 18 18:31:37 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Jun 2009 23:31:37 -0000 Subject: [llvm-commits] [llvm] r73736 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/Target/ARM/ARMTargetAsmInfo.cpp lib/Target/CellSPU/SPUTargetAsmInfo.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86TargetAsmInfo.cpp lib/Target/XCore/XCoreTargetAsmInfo.cpp Message-ID: <200906182331.n5INVbok024253@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 18:31:37 2009 New Revision: 73736 URL: http://llvm.org/viewvc/llvm-project?rev=73736&view=rev Log: simplify macro debug info directive handling. Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp llvm/trunk/lib/Target/TargetAsmInfo.cpp llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=73736&r1=73735&r2=73736&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Thu Jun 18 18:31:37 2009 @@ -472,10 +472,6 @@ /// encode inline subroutine information. bool DwarfUsesInlineInfoSection; // Defaults to false. - /// SupportsMacInfo - true if the Dwarf output supports macro information - /// - bool SupportsMacInfoSection; // Defaults to true - /// NonLocalEHFrameLabel - If set, the EH_frame label needs to be non-local. /// bool NonLocalEHFrameLabel; // Defaults to false. @@ -536,9 +532,9 @@ /// const char *DwarfRangesSection; // Defaults to ".debug_ranges". - /// DwarfMacInfoSection - Section directive for Dwarf info. + /// DwarfMacroInfoSection - Section directive for DWARF macro info. /// - const char *DwarfMacInfoSection; // Defaults to ".debug_macinfo". + const char *DwarfMacroInfoSection; // Defaults to ".debug_macinfo". /// DwarfEHFrameSection - Section directive for Exception frames. /// @@ -866,9 +862,6 @@ bool doesDwarfUsesInlineInfoSection() const { return DwarfUsesInlineInfoSection; } - bool doesSupportMacInfoSection() const { - return SupportsMacInfoSection; - } bool doesRequireNonLocalEHFrameLabel() const { return NonLocalEHFrameLabel; } @@ -914,8 +907,8 @@ const char *getDwarfRangesSection() const { return DwarfRangesSection; } - const char *getDwarfMacInfoSection() const { - return DwarfMacInfoSection; + const char *getDwarfMacroInfoSection() const { + return DwarfMacroInfoSection; } const char *getDwarfEHFrameSection() const { return DwarfEHFrameSection; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=73736&r1=73735&r2=73736&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Jun 18 18:31:37 2009 @@ -1995,8 +1995,8 @@ Asm->SwitchToDataSection(TAI->getDwarfARangesSection()); EmitLabel("section_aranges", 0); - if (TAI->doesSupportMacInfoSection()) { - Asm->SwitchToDataSection(TAI->getDwarfMacInfoSection()); + if (const char *LineInfoDirective = TAI->getDwarfMacroInfoSection()) { + Asm->SwitchToDataSection(LineInfoDirective); EmitLabel("section_macinfo", 0); } @@ -2542,9 +2542,9 @@ /// EmitDebugMacInfo - Emit visible names into a debug macinfo section. /// void DwarfDebug::EmitDebugMacInfo() { - if (TAI->doesSupportMacInfoSection()) { + if (const char *LineInfoDirective = TAI->getDwarfMacroInfoSection()) { // Start the dwarf macinfo section. - Asm->SwitchToDataSection(TAI->getDwarfMacInfoSection()); + Asm->SwitchToDataSection(LineInfoDirective); Asm->EOL(); } } Modified: llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp?rev=73736&r1=73735&r2=73736&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp Thu Jun 18 18:31:37 2009 @@ -90,7 +90,7 @@ DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; - DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; + DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; } ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM): @@ -115,7 +115,7 @@ DwarfLocSection = "\t.section\t.debug_loc,\"\",%progbits"; DwarfARangesSection = "\t.section\t.debug_aranges,\"\",%progbits"; DwarfRangesSection = "\t.section\t.debug_ranges,\"\",%progbits"; - DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",%progbits"; + DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",%progbits"; if (Subtarget->isAAPCS_ABI()) { StaticCtorsSection = "\t.section .init_array,\"aw\",%init_array"; Modified: llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp?rev=73736&r1=73735&r2=73736&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUTargetAsmInfo.cpp Thu Jun 18 18:31:37 2009 @@ -41,7 +41,6 @@ SupportsDebugInformation = true; NeedsSet = true; - SupportsMacInfoSection = false; DwarfAbbrevSection = "\t.section .debug_abbrev,\"\", at progbits"; DwarfInfoSection = "\t.section .debug_info,\"\", at progbits"; DwarfLineSection = "\t.section .debug_line,\"\", at progbits"; @@ -52,7 +51,7 @@ DwarfLocSection = "\t.section .debug_loc,\"\", at progbits"; DwarfARangesSection = "\t.section .debug_aranges,\"\", at progbits"; DwarfRangesSection = "\t.section .debug_ranges,\"\", at progbits"; - DwarfMacInfoSection = "\t.section .debug_macinfo,\"\",progbits"; + DwarfMacroInfoSection = 0; // macro info not supported. // Exception handling is not supported on CellSPU (think about it: you only // have 256K for code+data. Would you support exception handling?) Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp?rev=73736&r1=73735&r2=73736&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Thu Jun 18 18:31:37 2009 @@ -64,7 +64,7 @@ DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; - DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; + DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; // In non-PIC modes, emit a special label before jump tables so that the // linker can perform more accurate dead code stripping. @@ -130,7 +130,7 @@ DwarfLocSection = "\t.section\t.debug_loc,\"\", at progbits"; DwarfARangesSection = "\t.section\t.debug_aranges,\"\", at progbits"; DwarfRangesSection = "\t.section\t.debug_ranges,\"\", at progbits"; - DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\", at progbits"; + DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\", at progbits"; PCSymbol = "."; Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=73736&r1=73735&r2=73736&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Thu Jun 18 18:31:37 2009 @@ -102,7 +102,6 @@ SupportsExceptionHandling = false; DwarfRequiresFrameSection = true; DwarfUsesInlineInfoSection = false; - SupportsMacInfoSection = true; NonLocalEHFrameLabel = false; GlobalEHDirective = 0; SupportsWeakOmittedEHFrame = true; @@ -118,7 +117,7 @@ DwarfLocSection = ".debug_loc"; DwarfARangesSection = ".debug_aranges"; DwarfRangesSection = ".debug_ranges"; - DwarfMacInfoSection = ".debug_macinfo"; + DwarfMacroInfoSection = ".debug_macinfo"; DwarfEHFrameSection = ".eh_frame"; DwarfExceptionSection = ".gcc_except_table"; AsmTransCBE = 0; Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=73736&r1=73735&r2=73736&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Thu Jun 18 18:31:37 2009 @@ -118,7 +118,7 @@ DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; - DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; + DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; // Exceptions handling SupportsExceptionHandling = true; @@ -176,7 +176,7 @@ DwarfLocSection = "\t.section\t.debug_loc,\"\", at progbits"; DwarfARangesSection = "\t.section\t.debug_aranges,\"\", at progbits"; DwarfRangesSection = "\t.section\t.debug_ranges,\"\", at progbits"; - DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\", at progbits"; + DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\", at progbits"; // Exceptions handling SupportsExceptionHandling = true; @@ -259,7 +259,7 @@ DwarfLocSection = "\t.section\t.debug_loc,\"dr\""; DwarfARangesSection = "\t.section\t.debug_aranges,\"dr\""; DwarfRangesSection = "\t.section\t.debug_ranges,\"dr\""; - DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"dr\""; + DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"dr\""; } unsigned Modified: llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp?rev=73736&r1=73735&r2=73736&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp Thu Jun 18 18:31:37 2009 @@ -64,7 +64,7 @@ DwarfLocSection = "\t.section\t.debug_loc,\"\", at progbits"; DwarfARangesSection = "\t.section\t.debug_aranges,\"\", at progbits"; DwarfRangesSection = "\t.section\t.debug_ranges,\"\", at progbits"; - DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\", at progbits"; + DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\", at progbits"; } const Section* From sabre at nondot.org Thu Jun 18 18:33:14 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Jun 2009 23:33:14 -0000 Subject: [llvm-commits] [llvm] r73737 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Message-ID: <200906182333.n5INXEFv024353@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 18:33:13 2009 New Revision: 73737 URL: http://llvm.org/viewvc/llvm-project?rev=73737&view=rev Log: minor cleanup Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=73737&r1=73736&r2=73737&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Thu Jun 18 18:33:13 2009 @@ -29,13 +29,11 @@ bool verbose) { const X86Subtarget *Subtarget = &tm.getSubtarget(); - if (Subtarget->isFlavorIntel()) { + if (Subtarget->isFlavorIntel()) return new X86IntelAsmPrinter(o, tm, tm.getTargetAsmInfo(), OptLevel, verbose); - } else { - return new X86ATTAsmPrinter(o, tm, tm.getTargetAsmInfo(), - OptLevel, verbose); - } + return new X86ATTAsmPrinter(o, tm, tm.getTargetAsmInfo(), + OptLevel, verbose); } namespace { From sabre at nondot.org Thu Jun 18 18:41:36 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Jun 2009 23:41:36 -0000 Subject: [llvm-commits] [llvm] r73738 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/ARM/ARMTargetAsmInfo.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp lib/Target/X86/X86TargetAsmInfo.cpp Message-ID: <200906182341.n5INfaSF024864@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 18:41:35 2009 New Revision: 73738 URL: http://llvm.org/viewvc/llvm-project?rev=73738&view=rev Log: move mangler quote handling from asm printers to TargetAsmInfo. Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp llvm/trunk/lib/Target/TargetAsmInfo.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=73738&r1=73737&r2=73738&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Thu Jun 18 18:41:35 2009 @@ -278,6 +278,10 @@ /// use '\1' as the first character. const char *StringConstantPrefix; // Defaults to ".str" + /// AllowQuotesInName - This is true if the assembler allows for complex + /// symbol names to be surrounded in quotes. This defaults to false. + bool AllowQuotesInName; + //===--- Data Emission Directives -------------------------------------===// /// ZeroDirective - this should be set to the directive used to get some @@ -745,6 +749,9 @@ const char *getStringConstantPrefix() const { return StringConstantPrefix; } + bool doesAllowQuotesInName() const { + return AllowQuotesInName; + } const char *getZeroDirective() const { return ZeroDirective; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=73738&r1=73737&r2=73738&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Jun 18 18:41:35 2009 @@ -152,6 +152,9 @@ bool AsmPrinter::doInitialization(Module &M) { Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix()); + if (TAI->doesAllowQuotesInName()) + Mang->setUseQuotes(true); + GCModuleInfo *MI = getAnalysisIfAvailable(); assert(MI && "AsmPrinter didn't require GCModuleInfo?"); Modified: llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp?rev=73738&r1=73737&r2=73738&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp Thu Jun 18 18:41:35 2009 @@ -17,31 +17,31 @@ #include using namespace llvm; - const char *const llvm::arm_asm_table[] = { - "{r0}", "r0", - "{r1}", "r1", - "{r2}", "r2", - "{r3}", "r3", - "{r4}", "r4", - "{r5}", "r5", - "{r6}", "r6", - "{r7}", "r7", - "{r8}", "r8", - "{r9}", "r9", - "{r10}", "r10", - "{r11}", "r11", - "{r12}", "r12", - "{r13}", "r13", - "{r14}", "r14", - "{lr}", "lr", - "{sp}", "sp", - "{ip}", "ip", - "{fp}", "fp", - "{sl}", "sl", - "{memory}", "memory", - "{cc}", "cc", - 0,0}; + "{r0}", "r0", + "{r1}", "r1", + "{r2}", "r2", + "{r3}", "r3", + "{r4}", "r4", + "{r5}", "r5", + "{r6}", "r6", + "{r7}", "r7", + "{r8}", "r8", + "{r9}", "r9", + "{r10}", "r10", + "{r11}", "r11", + "{r12}", "r12", + "{r13}", "r13", + "{r14}", "r14", + "{lr}", "lr", + "{sp}", "sp", + "{ip}", "ip", + "{fp}", "fp", + "{sl}", "sl", + "{memory}", "memory", + "{cc}", "cc", + 0,0 +}; ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM): ARMTargetAsmInfo(TM) { @@ -64,6 +64,8 @@ HasDotTypeDotSizeDirective = false; HasSingleParameterDotFile = false; NeedsIndirectEncoding = true; + AllowQuotesInName = true; + if (TM.getRelocationModel() == Reloc::Static) { StaticCtorsSection = ".constructor"; StaticDtorsSection = ".destructor"; Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=73738&r1=73737&r2=73738&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Thu Jun 18 18:41:35 2009 @@ -836,10 +836,6 @@ assert(DW && "Dwarf Writer is not available"); DW->BeginModule(&M, MMI, O, this, TAI); - // Darwin wants symbols to be quoted if they have complex names. - if (Subtarget->isTargetDarwin()) - Mang->setUseQuotes(true); - // Thumb-2 instructions are supported only in unified assembler syntax mode. if (Subtarget->hasThumb2()) O << "\t.syntax unified\n"; Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=73738&r1=73737&r2=73738&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Thu Jun 18 18:41:35 2009 @@ -654,9 +654,6 @@ assert(DW && "DwarfWriter is not available"); DW->BeginModule(&M, MMI, O, this, TAI); - // GNU as handles section names wrapped in quotes - Mang->setUseQuotes(true); - SwitchToSection(TAI->getTextSection()); return Result; @@ -885,9 +882,6 @@ assert(DW && "DwarfWriter is not available"); DW->BeginModule(&M, MMI, O, this, TAI); - // Darwin wants symbols to be quoted if they have complex names. - Mang->setUseQuotes(true); - // Prime text sections so they are adjacent. This reduces the likelihood a // large data or debug section causes a branch to exceed 16M limit. SwitchToTextSection("\t.section __TEXT,__textcoal_nt,coalesced," Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp?rev=73738&r1=73737&r2=73738&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Thu Jun 18 18:41:35 2009 @@ -45,6 +45,7 @@ HiddenDirective = "\t.private_extern "; SupportsExceptionHandling = true; NeedsIndirectEncoding = true; + AllowQuotesInName = true; NeedsSet = true; BSSSection = 0; Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=73738&r1=73737&r2=73738&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Thu Jun 18 18:41:35 2009 @@ -58,6 +58,7 @@ InlineAsmEnd = "#NO_APP"; AssemblerDialect = 0; StringConstantPrefix = ".str"; + AllowQuotesInName = false; ZeroDirective = "\t.zero\t"; ZeroDirectiveSuffix = 0; AsciiDirective = "\t.ascii\t"; Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73738&r1=73737&r2=73738&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Thu Jun 18 18:41:35 2009 @@ -781,10 +781,6 @@ DW->BeginModule(&M, MMI, O, this, TAI); } - // Darwin wants symbols to be quoted if they have complex names. - if (Subtarget->isTargetDarwin()) - Mang->setUseQuotes(true); - return Result; } Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=73738&r1=73737&r2=73738&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Thu Jun 18 18:41:35 2009 @@ -86,6 +86,7 @@ PersonalitySuffix = "$non_lazy_ptr"; } NeedsIndirectEncoding = true; + AllowQuotesInName = true; InlineAsmStart = "## InlineAsm Start"; InlineAsmEnd = "## InlineAsm End"; CommentString = "##"; From sabre at nondot.org Thu Jun 18 18:46:04 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 18 Jun 2009 23:46:04 -0000 Subject: [llvm-commits] [llvm] r73739 - /llvm/trunk/tools/llvm-mc/CMakeLists.txt Message-ID: <200906182346.n5INk4Uk025136@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 18:46:04 2009 New Revision: 73739 URL: http://llvm.org/viewvc/llvm-project?rev=73739&view=rev Log: fix build problem pointed out by John Thompson! Modified: llvm/trunk/tools/llvm-mc/CMakeLists.txt Modified: llvm/trunk/tools/llvm-mc/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/CMakeLists.txt?rev=73739&r1=73738&r2=73739&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/CMakeLists.txt (original) +++ llvm/trunk/tools/llvm-mc/CMakeLists.txt Thu Jun 18 18:46:04 2009 @@ -1,5 +1,5 @@ set(LLVM_LINK_COMPONENTS support) -add_llvm_tool(llvm-dis +add_llvm_tool(llvm-mc llvm-mc.cpp ) From sabre at nondot.org Thu Jun 18 19:08:40 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Jun 2009 00:08:40 -0000 Subject: [llvm-commits] [llvm] r73742 - in /llvm/trunk: include/llvm/Target/DarwinTargetAsmInfo.h include/llvm/Target/TargetAsmInfo.h lib/Target/ARM/ARMTargetAsmInfo.cpp lib/Target/ARM/ARMTargetAsmInfo.h lib/Target/DarwinTargetAsmInfo.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86TargetAsmInfo.cpp Message-ID: <200906190008.n5J08ed9026706@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 19:08:39 2009 New Revision: 73742 URL: http://llvm.org/viewvc/llvm-project?rev=73742&view=rev Log: merge the common darwin settings from the X86/PPC/ARM targets into DarwinTargetAsmInfo.cpp. The remaining differences should be evaluated. It seems strange that x86/arm has .zerofill but ppc doesn't, etc. Modified: llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h llvm/trunk/include/llvm/Target/TargetAsmInfo.h llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.h llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp llvm/trunk/lib/Target/TargetAsmInfo.cpp llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Modified: llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h?rev=73742&r1=73741&r2=73742&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h (original) +++ llvm/trunk/include/llvm/Target/DarwinTargetAsmInfo.h Thu Jun 18 19:08:39 2009 @@ -23,7 +23,7 @@ class Type; class Mangler; - struct DarwinTargetAsmInfo: public TargetAsmInfo { + struct DarwinTargetAsmInfo : public TargetAsmInfo { const Section* TextCoalSection; const Section* ConstTextCoalSection; const Section* ConstDataCoalSection; Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=73742&r1=73741&r2=73742&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Thu Jun 18 19:08:39 2009 @@ -130,7 +130,6 @@ private: mutable StringMap
    Sections; mutable SectionFlags::FlagsStringsMapType FlagsStrings; - void fillDefaultValues(); protected: /// TM - The current TargetMachine. const TargetMachine &TM; @@ -312,8 +311,7 @@ /// directives for various sizes and non-default address spaces. virtual const char *getASDirective(unsigned size, unsigned AS) const { - assert (AS > 0 - && "Dont know the directives for default addr space"); + assert(AS > 0 && "Dont know the directives for default addr space"); return NULL; } Modified: llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp?rev=73742&r1=73741&r2=73742&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp Thu Jun 18 19:08:39 2009 @@ -47,52 +47,11 @@ ARMTargetAsmInfo(TM) { Subtarget = &TM.getSubtarget(); - GlobalPrefix = "_"; - PrivateGlobalPrefix = "L"; - LessPrivateGlobalPrefix = "l"; - StringConstantPrefix = "\1LC"; - BSSSection = 0; // no BSS section ZeroDirective = "\t.space\t"; ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill SetDirective = "\t.set\t"; - WeakRefDirective = "\t.weak_reference\t"; - WeakDefDirective = "\t.weak_definition "; - HiddenDirective = "\t.private_extern\t"; ProtectedDirective = NULL; - JumpTableDataSection = ".const"; - CStringSection = "\t.cstring"; HasDotTypeDotSizeDirective = false; - HasSingleParameterDotFile = false; - NeedsIndirectEncoding = true; - AllowQuotesInName = true; - - if (TM.getRelocationModel() == Reloc::Static) { - StaticCtorsSection = ".constructor"; - StaticDtorsSection = ".destructor"; - } else { - StaticCtorsSection = ".mod_init_func"; - StaticDtorsSection = ".mod_term_func"; - } - - // In non-PIC modes, emit a special label before jump tables so that the - // linker can perform more accurate dead code stripping. - // Emit a local label that is preserved until the linker runs. - // We do not check the relocation model here since it can be overridden - // later. - JumpTableSpecialLabelPrefix = "l"; - - NeedsSet = true; - DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; - DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug"; - DwarfLineSection = ".section __DWARF,__debug_line,regular,debug"; - DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug"; - DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug"; - DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug"; - DwarfStrSection = ".section __DWARF,__debug_str,regular,debug"; - DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; - DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; - DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; - DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; } ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM): Modified: llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.h?rev=73742&r1=73741&r2=73742&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.h Thu Jun 18 19:08:39 2009 @@ -26,8 +26,7 @@ template struct ARMTargetAsmInfo : public BaseTAI { - explicit ARMTargetAsmInfo(const ARMTargetMachine &TM): - BaseTAI(TM) { + explicit ARMTargetAsmInfo(const ARMTargetMachine &TM) : BaseTAI(TM) { BaseTAI::AsmTransCBE = arm_asm_table; BaseTAI::AlignmentIsInBytes = false; Modified: llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp?rev=73742&r1=73741&r2=73742&view=diff ============================================================================== --- llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/DarwinTargetAsmInfo.cpp Thu Jun 18 19:08:39 2009 @@ -50,6 +50,53 @@ ConstDataSection = getUnnamedSection(".const_data", SectionFlags::None); DataCoalSection = getNamedSection("\t__DATA,__datacoal_nt,coalesced", SectionFlags::Writeable); + + + // Common settings for all Darwin targets. + // Syntax: + GlobalPrefix = "_"; + PrivateGlobalPrefix = "L"; + LessPrivateGlobalPrefix = "l"; // Marker for some ObjC metadata + StringConstantPrefix = "\1LC"; + NeedsSet = true; + NeedsIndirectEncoding = true; + AllowQuotesInName = true; + HasSingleParameterDotFile = false; + + // In non-PIC modes, emit a special label before jump tables so that the + // linker can perform more accurate dead code stripping. We do not check the + // relocation model here since it can be overridden later. + JumpTableSpecialLabelPrefix = "l"; + + // Directives: + WeakDefDirective = "\t.weak_definition "; + WeakRefDirective = "\t.weak_reference "; + HiddenDirective = "\t.private_extern "; + + // Sections: + CStringSection = "\t.cstring"; + JumpTableDataSection = "\t.const\n"; + BSSSection = 0; + + if (TM.getRelocationModel() == Reloc::Static) { + StaticCtorsSection = ".constructor"; + StaticDtorsSection = ".destructor"; + } else { + StaticCtorsSection = ".mod_init_func"; + StaticDtorsSection = ".mod_term_func"; + } + + DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; + DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug"; + DwarfLineSection = ".section __DWARF,__debug_line,regular,debug"; + DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug"; + DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug"; + DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug"; + DwarfStrSection = ".section __DWARF,__debug_str,regular,debug"; + DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; + DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; + DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; + DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; } /// emitUsedDirectiveFor - On Darwin, internally linked data beginning with Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp?rev=73742&r1=73741&r2=73742&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Thu Jun 18 19:08:39 2009 @@ -19,59 +19,19 @@ using namespace llvm; using namespace llvm::dwarf; -PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM): +PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM) : PPCTargetAsmInfo(TM) { PCSymbol = "."; CommentString = ";"; - GlobalPrefix = "_"; - PrivateGlobalPrefix = "L"; - LessPrivateGlobalPrefix = "l"; - StringConstantPrefix = "\1LC"; ConstantPoolSection = "\t.const\t"; - JumpTableDataSection = ".const"; - CStringSection = "\t.cstring"; - if (TM.getRelocationModel() == Reloc::Static) { - StaticCtorsSection = ".constructor"; - StaticDtorsSection = ".destructor"; - } else { - StaticCtorsSection = ".mod_init_func"; - StaticDtorsSection = ".mod_term_func"; - } - HasSingleParameterDotFile = false; - SwitchToSectionDirective = "\t.section "; UsedDirective = "\t.no_dead_strip\t"; - WeakDefDirective = "\t.weak_definition "; - WeakRefDirective = "\t.weak_reference "; - HiddenDirective = "\t.private_extern "; SupportsExceptionHandling = true; - NeedsIndirectEncoding = true; - AllowQuotesInName = true; - NeedsSet = true; - BSSSection = 0; DwarfEHFrameSection = - ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support"; + ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support"; DwarfExceptionSection = ".section __DATA,__gcc_except_tab"; GlobalEHDirective = "\t.globl\t"; SupportsWeakOmittedEHFrame = false; - - DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; - DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug"; - DwarfLineSection = ".section __DWARF,__debug_line,regular,debug"; - DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug"; - DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug"; - DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug"; - DwarfStrSection = ".section __DWARF,__debug_str,regular,debug"; - DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; - DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; - DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; - DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; - - // In non-PIC modes, emit a special label before jump tables so that the - // linker can perform more accurate dead code stripping. - // We do not check the relocation model here since it can be overridden - // later. - JumpTableSpecialLabelPrefix = "l"; } /// PreferredEHDataFormat - This hook allows the target to select data Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=73742&r1=73741&r2=73742&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Thu Jun 18 19:08:39 2009 @@ -24,10 +24,10 @@ #include "llvm/Support/Dwarf.h" #include #include - using namespace llvm; -void TargetAsmInfo::fillDefaultValues() { +TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm) +: TM(tm) { BSSSection = "\t.bss"; BSSSection_ = 0; ReadOnlySection = 0; @@ -126,11 +126,6 @@ DataSection = getUnnamedSection("\t.data", SectionFlags::Writeable); } -TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm) - : TM(tm) { - fillDefaultValues(); -} - TargetAsmInfo::~TargetAsmInfo() { } Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=73742&r1=73741&r2=73742&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Thu Jun 18 19:08:39 2009 @@ -44,40 +44,25 @@ AlignmentIsInBytes = false; TextAlignFillValue = 0x90; - GlobalPrefix = "_"; + + if (!is64Bit) Data64bitsDirective = 0; // we can't emit a 64-bit unit ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. - PrivateGlobalPrefix = "L"; // Marker for constant pool idxs - LessPrivateGlobalPrefix = "l"; // Marker for some ObjC metadata - BSSSection = 0; // no BSS section. ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill if (TM.getRelocationModel() != Reloc::Static) ConstantPoolSection = "\t.const_data"; else ConstantPoolSection = "\t.const\n"; - JumpTableDataSection = "\t.const\n"; - CStringSection = "\t.cstring"; - // FIXME: Why don't always use this section? - if (is64Bit) { + // FIXME: Why don't we always use this section? + if (is64Bit) SixteenByteConstantSection = getUnnamedSection("\t.literal16\n", SectionFlags::Mergeable); - } LCOMMDirective = "\t.lcomm\t"; - SwitchToSectionDirective = "\t.section "; - StringConstantPrefix = "\1LC"; // Leopard and above support aligned common symbols. COMMDirectiveTakesAlignment = (Subtarget->getDarwinVers() >= 9); HasDotTypeDotSizeDirective = false; - HasSingleParameterDotFile = false; NonLocalEHFrameLabel = true; - if (TM.getRelocationModel() == Reloc::Static) { - StaticCtorsSection = ".constructor"; - StaticDtorsSection = ".destructor"; - } else { - StaticCtorsSection = ".mod_init_func"; - StaticDtorsSection = ".mod_term_func"; - } if (is64Bit) { PersonalityPrefix = ""; PersonalitySuffix = "+4 at GOTPCREL"; @@ -85,41 +70,18 @@ PersonalityPrefix = "L"; PersonalitySuffix = "$non_lazy_ptr"; } - NeedsIndirectEncoding = true; - AllowQuotesInName = true; InlineAsmStart = "## InlineAsm Start"; InlineAsmEnd = "## InlineAsm End"; CommentString = "##"; SetDirective = "\t.set"; PCSymbol = "."; UsedDirective = "\t.no_dead_strip\t"; - WeakDefDirective = "\t.weak_definition "; - WeakRefDirective = "\t.weak_reference "; - HiddenDirective = "\t.private_extern "; ProtectedDirective = "\t.globl\t"; - // In non-PIC modes, emit a special label before jump tables so that the - // linker can perform more accurate dead code stripping. - // Emit a local label that is preserved until the linker runs. - // We do not check the relocation model here since it can be overridden - // later. - JumpTableSpecialLabelPrefix = "l"; - SupportsDebugInformation = true; - NeedsSet = true; - DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; - DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug"; - DwarfLineSection = ".section __DWARF,__debug_line,regular,debug"; - DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug"; - DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug"; - DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug"; + DwarfDebugInlineSection = ".section __DWARF,__debug_inlined,regular,debug"; DwarfUsesInlineInfoSection = true; - DwarfStrSection = ".section __DWARF,__debug_str,regular,debug"; - DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; - DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; - DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; - DwarfMacroInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; // Exceptions handling SupportsExceptionHandling = true; From dalej at apple.com Thu Jun 18 19:11:45 2009 From: dalej at apple.com (Dale Johannesen) Date: Thu, 18 Jun 2009 17:11:45 -0700 Subject: [llvm-commits] [llvm] r73742 - in /llvm/trunk: include/llvm/Target/DarwinTargetAsmInfo.h include/llvm/Target/TargetAsmInfo.h lib/Target/ARM/ARMTargetAsmInfo.cpp lib/Target/ARM/ARMTargetAsmInfo.h lib/Target/DarwinTargetAsmInfo.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86TargetAsmInfo.cpp In-Reply-To: <200906190008.n5J08ed9026706@zion.cs.uiuc.edu> References: <200906190008.n5J08ed9026706@zion.cs.uiuc.edu> Message-ID: <79F30265-58CB-411F-A91F-E73D963316AD@apple.com> On Jun 18, 2009, at 5:08 PMPDT, Chris Lattner wrote: > merge the common darwin settings from the X86/PPC/ARM targets > into DarwinTargetAsmInfo.cpp. The remaining differences should > be evaluated. It seems strange that x86/arm has .zerofill but ppc > doesn't, etc. Darwin ppc does have zerofill. From clattner at apple.com Thu Jun 18 19:36:32 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 18 Jun 2009 17:36:32 -0700 Subject: [llvm-commits] [llvm] r73742 - in /llvm/trunk: include/llvm/Target/DarwinTargetAsmInfo.h include/llvm/Target/TargetAsmInfo.h lib/Target/ARM/ARMTargetAsmInfo.cpp lib/Target/ARM/ARMTargetAsmInfo.h lib/Target/DarwinTargetAsmInfo.cpp lib/Target/PowerPC/PPCTargetAsmInfo.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86TargetAsmInfo.cpp In-Reply-To: <79F30265-58CB-411F-A91F-E73D963316AD@apple.com> References: <200906190008.n5J08ed9026706@zion.cs.uiuc.edu> <79F30265-58CB-411F-A91F-E73D963316AD@apple.com> Message-ID: <5492E7C9-D45E-45AC-AC97-FAD7DFF0ECE5@apple.com> On Jun 18, 2009, at 5:11 PM, Dale Johannesen wrote: > > On Jun 18, 2009, at 5:08 PMPDT, Chris Lattner wrote: > >> merge the common darwin settings from the X86/PPC/ARM targets >> into DarwinTargetAsmInfo.cpp. The remaining differences should >> be evaluated. It seems strange that x86/arm has .zerofill but ppc >> doesn't, etc. > > Darwin ppc does have zerofill. LLVM doesn't generate it :), can you investigate turning it on? It seems that the three asm printers should be very similiar in capabilities. -Chris From sabre at nondot.org Thu Jun 18 19:47:42 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Jun 2009 00:47:42 -0000 Subject: [llvm-commits] [llvm] r73743 - in /llvm/trunk: include/llvm/MC/ include/llvm/MC/MCInst.h lib/Target/X86/AsmPrinter/CMakeLists.txt lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Message-ID: <200906190047.n5J0lhms029145@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 19:47:33 2009 New Revision: 73743 URL: http://llvm.org/viewvc/llvm-project?rev=73743&view=rev Log: Add some scaffolding for a new experimental asmprinter implementation. The idea is that we want asmprinting to work by converting MachineInstrs into a new MCInst class, then the per-instruction asmprinter works on MCInst. MCInst and the new asmprinters will not depend on most of the llvm code generators. This allows building diassemblers that don't link in the whole llvm code generator. This is step #1 of many. Added: llvm/trunk/include/llvm/MC/ llvm/trunk/include/llvm/MC/MCInst.h Modified: llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Added: llvm/trunk/include/llvm/MC/MCInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInst.h?rev=73743&view=auto ============================================================================== --- llvm/trunk/include/llvm/MC/MCInst.h (added) +++ llvm/trunk/include/llvm/MC/MCInst.h Thu Jun 18 19:47:33 2009 @@ -0,0 +1,93 @@ +//===-- llvm/MC/MCInst.h - MCInst class -------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declaration of the MCInst and MCOperand classes, which +// is the basic representation used to represent low-level machine code +// instructions. +// +//===----------------------------------------------------------------------===// + + +#ifndef LLVM_MC_MCINST_H +#define LLVM_MC_MCINST_H + +#include "llvm/ADT/SmallVector.h" + +namespace llvm { + +/// MCOperand - Instances of this class represent operands of the MCInst class. +/// This is a simple discriminated union. +class MCOperand { + enum MachineOperandType { + kInvalid, ///< Uninitialized. + kRegister, ///< Register operand. + kImmediate ///< Immediate operand. + }; + unsigned char Kind; + + union { + unsigned RegVal; + uint64_t ImmVal; + }; +public: + + MCOperand() : Kind(kInvalid) {} + MCOperand(const MCOperand &RHS) { *this = RHS; } + + bool isReg() const { return Kind == kRegister; } + bool isImm() const { return Kind == kImmediate; } + + /// getReg - Returns the register number. + unsigned getReg() const { + assert(isReg() && "This is not a register operand!"); + return RegVal; + } + + /// setReg - Set the register number. + void setReg(unsigned Reg) { + assert(isReg() && "This is not a register operand!"); + RegVal = Reg; + } + + uint64_t getImm() const { + assert(isImm() && "This is not an immediate"); + return ImmVal; + } + void setImm(uint64_t Val) { + assert(isImm() && "This is not an immediate"); + ImmVal = Val; + } + + void MakeReg(unsigned Reg) { + Kind = kRegister; + RegVal = Reg; + } + void MakeImm(uint64_t Val) { + Kind = kImmediate; + ImmVal = Val; + } +}; + + +/// MCInst - Instances of this class represent a single low-level machine +/// instruction. +class MCInst { + unsigned Opcode; + SmallVector Operands; +public: + MCInst() : Opcode(~0U) {} + + + +}; + + +} // end namespace llvm + +#endif Modified: llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt?rev=73743&r1=73742&r2=73743&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/CMakeLists.txt Thu Jun 18 19:47:33 2009 @@ -2,6 +2,7 @@ add_partially_linked_object(LLVMX86AsmPrinter X86ATTAsmPrinter.cpp + X86ATTInstPrinter.cpp X86AsmPrinter.cpp X86IntelAsmPrinter.cpp ) Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73743&r1=73742&r2=73743&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Thu Jun 18 19:47:33 2009 @@ -26,8 +26,10 @@ #include "llvm/Type.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/MC/MCInst.h" #include "llvm/CodeGen/DwarfWriter.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetAsmInfo.h" @@ -36,6 +38,9 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed"); +static cl::opt NewAsmPrinter("experimental-asm-printer", + cl::Hidden); + static std::string getPICLabelString(unsigned FnNum, const TargetAsmInfo *TAI, const X86Subtarget* Subtarget) { @@ -763,6 +768,12 @@ void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) { ++EmittedInsts; + if (NewAsmPrinter) { + MCInst TmpInst; + // FIXME: Convert TmpInst. + printInstruction(TmpInst); + } + // Call the autogenerated instruction printer routines. printInstruction(MI); } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h?rev=73743&r1=73742&r2=73743&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Thu Jun 18 19:47:33 2009 @@ -27,6 +27,7 @@ namespace llvm { class MachineJumpTableInfo; +class MCInst; class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter { DwarfWriter *DW; @@ -63,6 +64,9 @@ /// machine instruction was sufficiently described to print it, otherwise it /// returns false. bool printInstruction(const MachineInstr *MI); + + bool printInstruction(const MCInst &TmpInst); + // These methods are used by the tablegen'erated instruction printer. void printOperand(const MachineInstr *MI, unsigned OpNo, From sabre at nondot.org Thu Jun 18 19:48:00 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Jun 2009 00:48:00 -0000 Subject: [llvm-commits] [llvm] r73744 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Message-ID: <200906190048.n5J0m0Xv029170@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 19:47:59 2009 New Revision: 73744 URL: http://llvm.org/viewvc/llvm-project?rev=73744&view=rev Log: add a file I missed, this goes with r73743 Added: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Added: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=73744&view=auto ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (added) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Thu Jun 18 19:47:59 2009 @@ -0,0 +1,22 @@ +//===-- X86ATTInstPrinter.cpp - AT&T assembly instruction printing --------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file includes code for rendering MCInst instances as AT&T-style +// assembly. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "asm-printer" +#include "llvm/MC/MCInst.h" +#include "X86ATTAsmPrinter.h" +using namespace llvm; + +bool X86ATTAsmPrinter::printInstruction(const MCInst &TmpInst) { + return true; +} \ No newline at end of file From resistor at mac.com Thu Jun 18 19:48:22 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 00:48:22 -0000 Subject: [llvm-commits] [llvm] r73745 - in /llvm/trunk/include/llvm/System: Mutex.h RWMutex.h Message-ID: <200906190048.n5J0mMWT029203@zion.cs.uiuc.edu> Author: resistor Date: Thu Jun 18 19:48:22 2009 New Revision: 73745 URL: http://llvm.org/viewvc/llvm-project?rev=73745&view=rev Log: Fix weird class-size-being-different problems. At some level this is being caused by config.h not being included everywhere. Modified: llvm/trunk/include/llvm/System/Mutex.h llvm/trunk/include/llvm/System/RWMutex.h Modified: llvm/trunk/include/llvm/System/Mutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Mutex.h?rev=73745&r1=73744&r2=73745&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Mutex.h (original) +++ llvm/trunk/include/llvm/System/Mutex.h Thu Jun 18 19:48:22 2009 @@ -68,9 +68,7 @@ /// @name Platform Dependent Data /// @{ private: -#ifdef ENABLE_THREADS void* data_; ///< We don't know what the data will be -#endif /// @} /// @name Do Not Implement Modified: llvm/trunk/include/llvm/System/RWMutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/RWMutex.h?rev=73745&r1=73744&r2=73745&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/RWMutex.h (original) +++ llvm/trunk/include/llvm/System/RWMutex.h Thu Jun 18 19:48:22 2009 @@ -68,9 +68,7 @@ /// @name Platform Dependent Data /// @{ private: -#ifdef ENABLE_THREADS void* data_; ///< We don't know what the data will be -#endif /// @} /// @name Do Not Implement @@ -85,12 +83,12 @@ /// indicates whether this mutex should become a no-op when we're not /// running in multithreaded mode. template - class SmartRWMutex : RWMutexImpl { + class SmartRWMutex : public RWMutexImpl { public: explicit SmartRWMutex() : RWMutexImpl() { } bool reader_acquire() { - if (!mt_only && llvm_is_multithreaded()) + if (!mt_only || llvm_is_multithreaded()) return RWMutexImpl::reader_acquire(); return true; } From eli.friedman at gmail.com Thu Jun 18 20:43:09 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 19 Jun 2009 01:43:09 -0000 Subject: [llvm-commits] [llvm] r73746 - in /llvm/trunk: lib/Target/ARM/ARMInstrThumb.td test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll Message-ID: <200906190143.n5J1h99X032493@zion.cs.uiuc.edu> Author: efriedma Date: Thu Jun 18 20:43:08 2009 New Revision: 73746 URL: http://llvm.org/viewvc/llvm-project?rev=73746&view=rev Log: Mark a few Thumb instructions commutable; just happened to spot this while experimenting. I'm reasonably sure this is correct, but please tell me if these instructions have some strange property which makes this change unsafe. Added: llvm/trunk/test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=73746&r1=73745&r2=73746&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Thu Jun 18 20:43:08 2009 @@ -277,6 +277,7 @@ // // Add with carry +let isCommutable = 1 in def tADC : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), "adc $dst, $rhs", [(set tGPR:$dst, (adde tGPR:$lhs, tGPR:$rhs))]>; @@ -311,6 +312,7 @@ def tADDspi : TIt<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs), "add $dst, $rhs * 4", []>; +let isCommutable = 1 in def tAND : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), "and $dst, $rhs", [(set tGPR:$dst, (and tGPR:$lhs, tGPR:$rhs))]>; @@ -358,6 +360,7 @@ // TODO: A7-37: CMP(3) - cmp hi regs +let isCommutable = 1 in def tEOR : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), "eor $dst, $rhs", [(set tGPR:$dst, (xor tGPR:$lhs, tGPR:$rhs))]>; @@ -399,6 +402,7 @@ "cpy $dst, $src\t@ hir2hir", []>; } // neverHasSideEffects +let isCommutable = 1 in def tMUL : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), "mul $dst, $rhs", [(set tGPR:$dst, (mul tGPR:$lhs, tGPR:$rhs))]>; @@ -411,6 +415,7 @@ "neg $dst, $src", [(set tGPR:$dst, (ineg tGPR:$src))]>; +let isCommutable = 1 in def tORR : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), "orr $dst, $rhs", [(set tGPR:$dst, (or tGPR:$lhs, tGPR:$rhs))]>; Added: llvm/trunk/test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll?rev=73746&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll Thu Jun 18 20:43:08 2009 @@ -0,0 +1,8 @@ +; RUN: llvm-as < %s | llc -march=thumb | grep r0 | count 1 + +define i32 @a(i32 %x, i32 %y) nounwind readnone { +entry: + %mul = mul i32 %y, %x ; [#uses=1] + ret i32 %mul +} + From evan.cheng at apple.com Thu Jun 18 20:51:51 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 19 Jun 2009 01:51:51 -0000 Subject: [llvm-commits] [llvm] r73747 - in /llvm/trunk/lib/Target/ARM: ARM.td ARMISelLowering.cpp ARMInstrInfo.td ARMSchedule.td ARMScheduleV6.td ARMSubtarget.h ARMTargetMachine.cpp ARMTargetMachine.h Message-ID: <200906190151.n5J1ppxj000350@zion.cs.uiuc.edu> Author: evancheng Date: Thu Jun 18 20:51:50 2009 New Revision: 73747 URL: http://llvm.org/viewvc/llvm-project?rev=73747&view=rev Log: Latency information for ARM v6. It's rough and not yet hooked up. Right now we are only using branch latency to determine if-conversion limits. Added: llvm/trunk/lib/Target/ARM/ARMSchedule.td llvm/trunk/lib/Target/ARM/ARMScheduleV6.td Modified: llvm/trunk/lib/Target/ARM/ARM.td llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMSubtarget.h llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/lib/Target/ARM/ARMTargetMachine.h Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=73747&r1=73746&r2=73747&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Thu Jun 18 20:51:50 2009 @@ -45,62 +45,72 @@ // ARM Processors supported. // -class Proc Features> - : Processor; +include "ARMSchedule.td" + +class ProcNoItin Features> + : Processor; // V4 Processors. -def : Proc<"generic", []>; -def : Proc<"arm8", []>; -def : Proc<"arm810", []>; -def : Proc<"strongarm", []>; -def : Proc<"strongarm110", []>; -def : Proc<"strongarm1100", []>; -def : Proc<"strongarm1110", []>; +def : ProcNoItin<"generic", []>; +def : ProcNoItin<"arm8", []>; +def : ProcNoItin<"arm810", []>; +def : ProcNoItin<"strongarm", []>; +def : ProcNoItin<"strongarm110", []>; +def : ProcNoItin<"strongarm1100", []>; +def : ProcNoItin<"strongarm1110", []>; // V4T Processors. -def : Proc<"arm7tdmi", [ArchV4T]>; -def : Proc<"arm7tdmi-s", [ArchV4T]>; -def : Proc<"arm710t", [ArchV4T]>; -def : Proc<"arm720t", [ArchV4T]>; -def : Proc<"arm9", [ArchV4T]>; -def : Proc<"arm9tdmi", [ArchV4T]>; -def : Proc<"arm920", [ArchV4T]>; -def : Proc<"arm920t", [ArchV4T]>; -def : Proc<"arm922t", [ArchV4T]>; -def : Proc<"arm940t", [ArchV4T]>; -def : Proc<"ep9312", [ArchV4T]>; +def : ProcNoItin<"arm7tdmi", [ArchV4T]>; +def : ProcNoItin<"arm7tdmi-s", [ArchV4T]>; +def : ProcNoItin<"arm710t", [ArchV4T]>; +def : ProcNoItin<"arm720t", [ArchV4T]>; +def : ProcNoItin<"arm9", [ArchV4T]>; +def : ProcNoItin<"arm9tdmi", [ArchV4T]>; +def : ProcNoItin<"arm920", [ArchV4T]>; +def : ProcNoItin<"arm920t", [ArchV4T]>; +def : ProcNoItin<"arm922t", [ArchV4T]>; +def : ProcNoItin<"arm940t", [ArchV4T]>; +def : ProcNoItin<"ep9312", [ArchV4T]>; // V5T Processors. -def : Proc<"arm10tdmi", [ArchV5T]>; -def : Proc<"arm1020t", [ArchV5T]>; +def : ProcNoItin<"arm10tdmi", [ArchV5T]>; +def : ProcNoItin<"arm1020t", [ArchV5T]>; // V5TE Processors. -def : Proc<"arm9e", [ArchV5TE]>; -def : Proc<"arm926ej-s", [ArchV5TE]>; -def : Proc<"arm946e-s", [ArchV5TE]>; -def : Proc<"arm966e-s", [ArchV5TE]>; -def : Proc<"arm968e-s", [ArchV5TE]>; -def : Proc<"arm10e", [ArchV5TE]>; -def : Proc<"arm1020e", [ArchV5TE]>; -def : Proc<"arm1022e", [ArchV5TE]>; -def : Proc<"xscale", [ArchV5TE]>; -def : Proc<"iwmmxt", [ArchV5TE]>; +def : ProcNoItin<"arm9e", [ArchV5TE]>; +def : ProcNoItin<"arm926ej-s", [ArchV5TE]>; +def : ProcNoItin<"arm946e-s", [ArchV5TE]>; +def : ProcNoItin<"arm966e-s", [ArchV5TE]>; +def : ProcNoItin<"arm968e-s", [ArchV5TE]>; +def : ProcNoItin<"arm10e", [ArchV5TE]>; +def : ProcNoItin<"arm1020e", [ArchV5TE]>; +def : ProcNoItin<"arm1022e", [ArchV5TE]>; +def : ProcNoItin<"xscale", [ArchV5TE]>; +def : ProcNoItin<"iwmmxt", [ArchV5TE]>; // V6 Processors. -def : Proc<"arm1136j-s", [ArchV6]>; -def : Proc<"arm1136jf-s", [ArchV6, FeatureVFP2]>; -def : Proc<"arm1176jz-s", [ArchV6]>; -def : Proc<"arm1176jzf-s", [ArchV6, FeatureVFP2]>; -def : Proc<"mpcorenovfp", [ArchV6]>; -def : Proc<"mpcore", [ArchV6, FeatureVFP2]>; +def : Processor<"arm1136j-s", V6Itineraries, + [ArchV6]>; +def : Processor<"arm1136jf-s", V6Itineraries, + [ArchV6, FeatureVFP2]>; +def : Processor<"arm1176jz-s", V6Itineraries, + [ArchV6]>; +def : Processor<"arm1176jzf-s", V6Itineraries, + [ArchV6, FeatureVFP2]>; +def : Processor<"mpcorenovfp", V6Itineraries, + [ArchV6]>; +def : Processor<"mpcore", V6Itineraries, + [ArchV6, FeatureVFP2]>; // V6T2 Processors. -def : Proc<"arm1156t2-s", [ArchV6T2, FeatureThumb2]>; -def : Proc<"arm1156t2f-s", [ArchV6T2, FeatureThumb2, FeatureVFP2]>; +def : Processor<"arm1156t2-s", V6Itineraries, + [ArchV6T2, FeatureThumb2]>; +def : Processor<"arm1156t2f-s", V6Itineraries, + [ArchV6T2, FeatureThumb2, FeatureVFP2]>; // V7 Processors. -def : Proc<"cortex-a8", [ArchV7A, FeatureThumb2, FeatureNEON]>; -def : Proc<"cortex-a9", [ArchV7A, FeatureThumb2, FeatureNEON]>; +def : ProcNoItin<"cortex-a8", [ArchV7A, FeatureThumb2, FeatureNEON]>; +def : ProcNoItin<"cortex-a9", [ArchV7A, FeatureThumb2, FeatureNEON]>; //===----------------------------------------------------------------------===// // Register File Description Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=73747&r1=73746&r2=73747&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Jun 18 20:51:50 2009 @@ -292,6 +292,21 @@ setIfCvtBlockSizeLimit(Subtarget->isThumb() ? 0 : 10); setIfCvtDupBlockSizeLimit(Subtarget->isThumb() ? 0 : 2); + if (!Subtarget->isThumb()) { + // Use branch latency information to determine if-conversion limits. + const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); + const InstrItineraryData &InstrItins = Subtarget->getInstrItineraryData(); + unsigned Latency = InstrItins.getLatency(TII->get(ARM::BL).getSchedClass()); + if (Latency > 1) { + setIfCvtBlockSizeLimit(Latency-1); + if (Latency > 2) + setIfCvtDupBlockSizeLimit(Latency-2); + } else { + setIfCvtBlockSizeLimit(10); + setIfCvtDupBlockSizeLimit(2); + } + } + maxStoresPerMemcpy = 1; //// temporary - rewrite interface to use type // Do not enable CodePlacementOpt for now: it currently runs after the // ARMConstantIslandPass and messes up branch relaxation and placement Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=73747&r1=73746&r2=73747&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Thu Jun 18 20:51:50 2009 @@ -539,7 +539,7 @@ LdStMulFrm, "ldm${p}${addr:submode} $addr, $dst1", []>; -let isCall = 1, +let isCall = 1, Itinerary = IIC_Br, Defs = [R0, R1, R2, R3, R12, LR, D0, D1, D2, D3, D4, D5, D6, D7, CPSR] in { def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops), @@ -567,7 +567,7 @@ } } -let isBranch = 1, isTerminator = 1 in { +let isBranch = 1, isTerminator = 1, Itinerary = IIC_Br in { // B is "predicable" since it can be xformed into a Bcc. let isBarrier = 1 in { let isPredicable = 1 in Added: llvm/trunk/lib/Target/ARM/ARMSchedule.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSchedule.td?rev=73747&view=auto ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSchedule.td (added) +++ llvm/trunk/lib/Target/ARM/ARMSchedule.td Thu Jun 18 20:51:50 2009 @@ -0,0 +1,35 @@ +//===- ARMSchedule.td - ARM Scheduling Definitions ---------*- tablegen -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +//===----------------------------------------------------------------------===// +// Functional units across ARM processors +// +def FU_iALU : FuncUnit; // Integer alu unit +def FU_iLdSt : FuncUnit; // Integer load / store unit +def FU_FpALU : FuncUnit; // FP alu unit +def FU_FpLdSt : FuncUnit; // FP load / store unit +def FU_Br : FuncUnit; // Branch unit + +//===----------------------------------------------------------------------===// +// Instruction Itinerary classes used for ARM +// +def IIC_iALU : InstrItinClass; +def IIC_iLoad : InstrItinClass; +def IIC_iStore : InstrItinClass; +def IIC_fpALU : InstrItinClass; +def IIC_fpLoad : InstrItinClass; +def IIC_fpStore : InstrItinClass; +def IIC_Br : InstrItinClass; + +//===----------------------------------------------------------------------===// +// Processor instruction itineraries. + +def GenericItineraries : ProcessorItineraries<[]>; + +include "ARMScheduleV6.td" Added: llvm/trunk/lib/Target/ARM/ARMScheduleV6.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMScheduleV6.td?rev=73747&view=auto ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMScheduleV6.td (added) +++ llvm/trunk/lib/Target/ARM/ARMScheduleV6.td Thu Jun 18 20:51:50 2009 @@ -0,0 +1,22 @@ +//===- ARMSchedule.td - ARM v6 Scheduling Definitions ------*- tablegen -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the itinerary class data for the ARM v6 processors. +// +//===----------------------------------------------------------------------===// + +def V6Itineraries : ProcessorItineraries<[ + InstrItinData]>, + InstrItinData]>, + InstrItinData]>, + InstrItinData]>, + InstrItinData]>, + InstrItinData]>, + InstrItinData]> +]>; Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=73747&r1=73746&r2=73747&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Thu Jun 18 20:51:50 2009 @@ -14,6 +14,7 @@ #ifndef ARMSUBTARGET_H #define ARMSUBTARGET_H +#include "llvm/Target/TargetInstrItineraries.h" #include "llvm/Target/TargetSubtarget.h" #include @@ -58,6 +59,9 @@ /// CPUString - String name of used CPU. std::string CPUString; + /// Selected instruction itineraries (one entry per itinerary class.) + InstrItineraryData InstrItins; + public: enum { isELF, isDarwin @@ -110,6 +114,10 @@ const std::string & getCPUString() const { return CPUString; } + /// getInstrItins - Return the instruction itineraies based on subtarget + /// selection. + const InstrItineraryData &getInstrItineraryData() const { return InstrItins; } + /// getStackAlignment - Returns the minimum alignment known to hold of the /// stack frame on entry to the function and which must be maintained by every /// function for this subtarget. Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=73747&r1=73746&r2=73747&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Thu Jun 18 20:51:50 2009 @@ -102,7 +102,8 @@ InstrInfo(Subtarget), FrameInfo(Subtarget), JITInfo(), - TLInfo(*this) { + TLInfo(*this), + InstrItins(Subtarget.getInstrItineraryData()) { DefRelocModel = getRelocationModel(); } Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.h?rev=73747&r1=73746&r2=73747&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.h (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.h Thu Jun 18 20:51:50 2009 @@ -28,13 +28,14 @@ class Module; class ARMTargetMachine : public LLVMTargetMachine { - ARMSubtarget Subtarget; - const TargetData DataLayout; // Calculates type size & alignment - ARMInstrInfo InstrInfo; - ARMFrameInfo FrameInfo; - ARMJITInfo JITInfo; - ARMTargetLowering TLInfo; - Reloc::Model DefRelocModel; // Reloc model before it's overridden. + ARMSubtarget Subtarget; + const TargetData DataLayout; // Calculates type size & alignment + ARMInstrInfo InstrInfo; + ARMFrameInfo FrameInfo; + ARMJITInfo JITInfo; + ARMTargetLowering TLInfo; + InstrItineraryData InstrItins; + Reloc::Model DefRelocModel; // Reloc model before it's overridden. protected: // To avoid having target depend on the asmprinter stuff libraries, asmprinter @@ -59,6 +60,9 @@ virtual ARMTargetLowering *getTargetLowering() const { return const_cast(&TLInfo); } + virtual const InstrItineraryData getInstrItineraryData() const { + return InstrItins; + } static void registerAsmPrinter(AsmPrinterCtorFn F) { AsmPrinterCtor = F; From xuzhongxing at gmail.com Thu Jun 18 20:56:53 2009 From: xuzhongxing at gmail.com (Zhongxing Xu) Date: Fri, 19 Jun 2009 01:56:53 -0000 Subject: [llvm-commits] [llvm] r73748 - /llvm/trunk/include/llvm/MC/MCInst.h Message-ID: <200906190156.n5J1urTb000497@zion.cs.uiuc.edu> Author: zhongxingxu Date: Thu Jun 18 20:56:53 2009 New Revision: 73748 URL: http://llvm.org/viewvc/llvm-project?rev=73748&view=rev Log: Include DataTypes.h for 'uint64_t'. Modified: llvm/trunk/include/llvm/MC/MCInst.h Modified: llvm/trunk/include/llvm/MC/MCInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInst.h?rev=73748&r1=73747&r2=73748&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCInst.h (original) +++ llvm/trunk/include/llvm/MC/MCInst.h Thu Jun 18 20:56:53 2009 @@ -18,6 +18,7 @@ #define LLVM_MC_MCINST_H #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/DataTypes.h" namespace llvm { From evan.cheng at apple.com Thu Jun 18 20:59:04 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 19 Jun 2009 01:59:04 -0000 Subject: [llvm-commits] [llvm] r73749 - /llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Message-ID: <200906190159.n5J1x4Mh000563@zion.cs.uiuc.edu> Author: evancheng Date: Thu Jun 18 20:59:04 2009 New Revision: 73749 URL: http://llvm.org/viewvc/llvm-project?rev=73749&view=rev Log: Transfer dead markers when a ldrd is changed into a ldm or a pair of ldr. Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=73749&r1=73748&r2=73749&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Thu Jun 18 20:59:04 2009 @@ -620,7 +620,7 @@ MachineBasicBlock::iterator &MBBI, int OffImm, bool isDef, DebugLoc dl, unsigned NewOpc, - unsigned Reg, bool RegKill, + unsigned Reg, bool RegDeadKill, unsigned BaseReg, bool BaseKill, unsigned OffReg, bool OffKill, ARMCC::CondCodes Pred, unsigned PredReg, @@ -631,14 +631,15 @@ else Offset = ARM_AM::getAM2Opc(ARM_AM::add, OffImm, ARM_AM::no_shift); if (isDef) - BuildMI(MBB, MBBI, MBBI->getDebugLoc(), TII->get(NewOpc), Reg) + BuildMI(MBB, MBBI, MBBI->getDebugLoc(), TII->get(NewOpc)) + .addReg(Reg, getDefRegState(true) | getDeadRegState(RegDeadKill)) .addReg(BaseReg, getKillRegState(BaseKill)) .addReg(OffReg, getKillRegState(OffKill)) .addImm(Offset) .addImm(Pred).addReg(PredReg); else BuildMI(MBB, MBBI, MBBI->getDebugLoc(), TII->get(NewOpc)) - .addReg(Reg, getKillRegState(RegKill)) + .addReg(Reg, getKillRegState(RegDeadKill)) .addReg(BaseReg, getKillRegState(BaseKill)) .addReg(OffReg, getKillRegState(OffKill)) .addImm(Offset) @@ -658,8 +659,10 @@ return false; bool isLd = Opcode == ARM::LDRD; - bool EvenKill = isLd ? false : MI->getOperand(0).isKill(); - bool OddKill = isLd ? false : MI->getOperand(1).isKill(); + bool EvenDeadKill = isLd ? + MI->getOperand(0).isDead() : MI->getOperand(0).isKill(); + bool OddDeadKill = isLd ? + MI->getOperand(1).isDead() : MI->getOperand(1).isKill(); const MachineOperand &BaseOp = MI->getOperand(2); unsigned BaseReg = BaseOp.getReg(); bool BaseKill = BaseOp.isKill(); @@ -679,16 +682,16 @@ .addReg(BaseReg, getKillRegState(BaseKill)) .addImm(ARM_AM::getAM4ModeImm(ARM_AM::ia)) .addImm(Pred).addReg(PredReg) - .addReg(EvenReg, getDefRegState(isLd)) - .addReg(OddReg, getDefRegState(isLd)); + .addReg(EvenReg, getDefRegState(isLd) | getDeadRegState(EvenDeadKill)) + .addReg(OddReg, getDefRegState(isLd) | getDeadRegState(OddDeadKill)); ++NumLDRD2LDM; } else { BuildMI(MBB, MBBI, MBBI->getDebugLoc(), TII->get(NewOpc)) .addReg(BaseReg, getKillRegState(BaseKill)) .addImm(ARM_AM::getAM4ModeImm(ARM_AM::ia)) .addImm(Pred).addReg(PredReg) - .addReg(EvenReg, getKillRegState(EvenKill)) - .addReg(OddReg, getKillRegState(OddKill)); + .addReg(EvenReg, getKillRegState(EvenDeadKill)) + .addReg(OddReg, getKillRegState(OddDeadKill)); ++NumSTRD2STM; } } else { @@ -703,15 +706,17 @@ (OffReg && TRI->regsOverlap(EvenReg, OffReg)))) { assert(!TRI->regsOverlap(OddReg, BaseReg) && (!OffReg || !TRI->regsOverlap(OddReg, OffReg))); - InsertLDR_STR(MBB, MBBI, OffImm+4, isLd, dl, NewOpc, OddReg, OddKill, + InsertLDR_STR(MBB, MBBI, OffImm+4, isLd, dl, NewOpc, OddReg, OddDeadKill, BaseReg, false, OffReg, false, Pred, PredReg, TII); - InsertLDR_STR(MBB, MBBI, OffImm, isLd, dl, NewOpc, EvenReg, EvenKill, + InsertLDR_STR(MBB, MBBI, OffImm, isLd, dl, NewOpc, EvenReg, EvenDeadKill, BaseReg, BaseKill, OffReg, OffKill, Pred, PredReg, TII); } else { - InsertLDR_STR(MBB, MBBI, OffImm, isLd, dl, NewOpc, EvenReg, EvenKill, - BaseReg, false, OffReg, false, Pred, PredReg, TII); - InsertLDR_STR(MBB, MBBI, OffImm+4, isLd, dl, NewOpc, OddReg, OddKill, - BaseReg, BaseKill, OffReg, OffKill, Pred, PredReg, TII); + InsertLDR_STR(MBB, MBBI, OffImm, isLd, dl, NewOpc, + EvenReg, EvenDeadKill, BaseReg, false, OffReg, false, + Pred, PredReg, TII); + InsertLDR_STR(MBB, MBBI, OffImm+4, isLd, dl, NewOpc, + OddReg, OddDeadKill, BaseReg, BaseKill, OffReg, OffKill, + Pred, PredReg, TII); } if (isLd) ++NumLDRD2LDR; From nicholas at mxc.ca Thu Jun 18 21:03:36 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 18 Jun 2009 19:03:36 -0700 Subject: [llvm-commits] [llvm] r73646 - /llvm/trunk/include/llvm/Support/IRBuilder.h In-Reply-To: <47A0715A-B487-443D-BE88-D9F52DF7AB9E@apple.com> References: <200906172220.n5HMKkX5007824@zion.cs.uiuc.edu> <2AC709DE-1579-427A-8D43-B0B0546791FE@apple.com> <47A0715A-B487-443D-BE88-D9F52DF7AB9E@apple.com> Message-ID: <4A3AF1F8.50308@mxc.ca> Chris Lattner wrote: > On Jun 18, 2009, at 1:10 AM, Anton Korobeynikov wrote: > >> Hi Chris >> >>> Anton, why isn't the caller and callee already getting the right >>> calling conv? This seems like the wrong fix, >> We have separate calling conv fields on, for example, Function and >> CallInst. That's why API user should put correct calling conv on >> CallInst during creation of such (see, for example, >> SimplifyCFGPass.cpp:ChangeToCall). By default CI's are created with C >> calling conv and in general we'll have calling conv mismatch between >> caller and callee if API user won't tune the calling conv of CI. >> >> SimplifyLibCalls pass uses IRBuilder to insert calls to strlen & >> friends. They can be already defined in the module with non-C calling >> convention, thus we need to put the same calling conv on CI also. I >> thought it's much safer to let IRBuilder to do this by default instead >> of letting each user to do this explicitly. Also, since custom CCs are >> not so frequent stuff, possible bugs due to CC mismatch might be >> pretty tricky to catch of we'll delegate tweaking of CC to API user. > > I discussed this with Anton on IRC and convinced (I think!) him to > revert the changes to IRBuilder. I'd like to keep it really obvious > how the IRbuilder interfaces relate to the generated IR. One of my > fears is that making this be "magic" will make enough stuff work in > the obvious cases that we'll be left with obscure bugs in the uncommon > cases. By making the client have to directly think about CC's, we > avoid some bugs. That's the situation now, after the revert. Things will work by "magic" almost all of the time, until we hit an obscure bug in the uncommon case that somebody actually set a non-zero CC on a function. If you really want to go down this road I suggest making the CC a required parameter to CreateCall. Nick From nicholas at mxc.ca Thu Jun 18 21:08:21 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 18 Jun 2009 19:08:21 -0700 Subject: [llvm-commits] [PATCH] fold umax(zext A, zext B) -> zext (umax(A, B)) In-Reply-To: References: <4A393785.8090202@gmail.com> <6C8ECC3B-BE0E-4D05-92B4-926E9FF6CD8B@apple.com> <4A3955A9.4040300@gmail.com> <25637945-0AD3-4F9C-9C96-DB4AB9A4CCC7@apple.com> <4A39EE9C.5070406@gmail.com> Message-ID: <4A3AF315.2070303@mxc.ca> Dan Gohman wrote: > On Jun 18, 2009, at 12:37 AM, T?r?k Edwin wrote: > > >> On 2009-06-18 01:12, Dan Gohman wrote: >> >>> On Jun 17, 2009, at 1:44 PM, T?r?k Edwin wrote: >>> >>> >>> >>> >>> >>> >>> >>>> On 2009-06-17 23:25, Dan Gohman wrote: >>>> >>>> >>>> >>>> >>>> >>>>> On Jun 17, 2009, at 11:35 AM, T?r?k Edwin wrote: >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>>> Hi, >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> I noticed that umax (zext t1 %X to %t0, zext t1 %Y to %t0) isn't >>>>>> >>>>>> >>>>>> >>>>>> folded, >>>>>> >>>>>> >>>>>> >>>>>> the attached patch folds this into: >>>>>> >>>>>> >>>>>> >>>>>> umax (zext t1 %X to %t0, zext t1 %Y to %t0). >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> It also folds umax (sext t1 %X to %t0, sext t1 %Y to %t0) -> sext >>>>>> >>>>>> t1 >>>>>> >>>>>> >>>>>> >>>>>> (umax (%X, %Y)) to %t0. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> zext is very often encountered in SCEV expressions on x86-64, >>>>>> since >>>>>> >>>>>> >>>>>> >>>>>> pointer indexes for GEP are i64. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> Thoughts? >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> Another question to ask is whether this kind of thing belongs in >>>>> >>>>> >>>>> >>>>> ScalarEvolution, or if it would be more appropriate for >>>>> >>>>> >>>>> >>>>> instcombine. Instcombine looks at all instructions in a program, >>>>> >>>>> >>>>> >>>>> while ScalarEvolution typically only looks at those related to >>>>> >>>>> >>>>> >>>>> loop iteration. Also, instcombine could more easily handle more >>>>> >>>>> >>>>> >>>>> generalized cases of this optimization, for example with umin. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On the other hand, there are cases where it makes sense to do >>>>> >>>>> >>>>> >>>>> such simplifications in ScalarEvolution. Can you given an >>>>> >>>>> >>>>> >>>>> example where you're seeing this kind of code? >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>> It doesn't have much to do with code generation/optimization, but >>>> >>>> rather >>>> >>>> with analysis. >>>> >>>> I have a pass that tries to find buffer overflow bugs, doing that >>>> >>>> involves lots of umax() expressions. >>>> >>>> If I can move the zext out of umax I can decide quite early that an >>>> >>>> access is valid: >>>> >>>> >>>> >>>> int foo(unsigned n, unsigned i) >>>> >>>> { >>>> >>>> char *a = malloc(n); >>>> >>>> if (!a) >>>> >>>> return -1; >>>> >>>> if (i < n) >>>> >>>> a[i]=0; >>>> >>>> } >>>> >>>> >>>> >>> >>> Where does the umax come from in this code? I guess that you're >>> >>> transforming it in some way; could you show what the code looks >>> >>> like after the transformation? >>> >>> >>> >> %0 = malloc i8, i32 %n ; [#uses=2] >> %2 = zext i32 %i to i64 ; [#uses=1] >> %3 = getelementptr i8* %0, i64 %2 ; [#uses=1] >> >> %3 is '((zext i32 %i to i64) + %0' according to SCEV, >> %0 has size %n => >> >> offset is (zext i32 %i to i64), hence one of the safety conditions >> is i >> >>> = 0 && i < n. We already have i >= 0 since I treat all >>> >> values as unsigned, so that leaves us with i < n: >> >> if ((zext i32 %n to i64) umax (zext i32 %i to i64)) == (zext i32 %i to >> i64) then access is always valid >> if ((zext i32 %n to i64) umax (zext i32 %i to i64)) == (zext i32 %n to >> i64) then access is always invalid > > Thanks, though it's still not clear why umax is needed. > Wouldn't the code be a lot simpler expanded like this: > > if (zext %i to i64) < (zext %n to i64) then access is always valid > else access is always invalid > > Stripping out the zexts from comparisons is fairly trivial. > >> Otherwise I use a solver to decide >> >> There are 2 more conditions (access size < size, offset + >> access_size < >> size) with similar expressions. >> As I said I could do the zext simplification in my pass only, but I >> thought this is something that would benefit SCEV(Expander) in >> general. > > I agree that the transformation sounds more generally applicable, > though umax is relatively uncommon in common SCEV usage, so I was > curious where you were seeing this kind of expression. Having > SCEVExpander do clever things is fine, though it's often easier > to just let it expand expressions in a simple way and let a > subsequent instcombine run tidy things up. I've gotten in trouble with Chris for that in the past, he says SCEV should not leave the IR any more complicated than when it saw it. A good way to achieve that is to always make changes to createSCEV and the SCEV expander in matching pairs. Nick From nicholas at mxc.ca Thu Jun 18 21:11:28 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 18 Jun 2009 19:11:28 -0700 Subject: [llvm-commits] [llvm] r73728 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h include/llvm/Analysis/ScalarEvolutionExpressions.h lib/Analysis/ScalarEvolution.cpp In-Reply-To: <200906182225.n5IMPNo4019977@zion.cs.uiuc.edu> References: <200906182225.n5IMPNo4019977@zion.cs.uiuc.edu> Message-ID: <4A3AF3D0.2070502@mxc.ca> Owen Anderson wrote: > Author: resistor > Date: Thu Jun 18 17:25:12 2009 > New Revision: 73728 > > URL: http://llvm.org/viewvc/llvm-project?rev=73728&view=rev > Log: > Add a parent pointer to SCEV, in preparation for getting rid of the global uniquing tables. No functionality change. Wait, what? Owen, would you mind explaining what your plans are here? Are you planning to no longer unique SCEVs? Nick > Modified: > llvm/trunk/include/llvm/Analysis/ScalarEvolution.h > llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h > llvm/trunk/lib/Analysis/ScalarEvolution.cpp > > Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=73728&r1=73727&r2=73728&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) > +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Thu Jun 18 17:25:12 2009 > @@ -53,12 +53,15 @@ > delete this; > } > > + const ScalarEvolution* parent; > + > SCEV(const SCEV &); // DO NOT IMPLEMENT > void operator=(const SCEV &); // DO NOT IMPLEMENT > protected: > virtual ~SCEV(); > public: > - explicit SCEV(unsigned SCEVTy) : SCEVType(SCEVTy), RefCount(0) {} > + explicit SCEV(unsigned SCEVTy, const ScalarEvolution* p) : > + SCEVType(SCEVTy), RefCount(0), parent(p) {} > > unsigned getSCEVType() const { return SCEVType; } > > @@ -126,7 +129,7 @@ > /// None of the standard SCEV operations are valid on this class, it is just a > /// marker. > struct SCEVCouldNotCompute : public SCEV { > - SCEVCouldNotCompute(); > + SCEVCouldNotCompute(const ScalarEvolution* p); > ~SCEVCouldNotCompute(); > > // None of these methods are valid for this object. > @@ -205,13 +208,13 @@ > template<> > struct DenseMapInfo { > static inline SCEVHandle getEmptyKey() { > - static SCEVCouldNotCompute Empty; > + static SCEVCouldNotCompute Empty(0); > if (Empty.RefCount == 0) > Empty.addRef(); > return &Empty; > } > static inline SCEVHandle getTombstoneKey() { > - static SCEVCouldNotCompute Tombstone; > + static SCEVCouldNotCompute Tombstone(0); > if (Tombstone.RefCount == 0) > Tombstone.addRef(); > return &Tombstone; > > Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h?rev=73728&r1=73727&r2=73728&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h (original) > +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Thu Jun 18 17:25:12 2009 > @@ -36,7 +36,8 @@ > friend class ScalarEvolution; > > ConstantInt *V; > - explicit SCEVConstant(ConstantInt *v) : SCEV(scConstant), V(v) {} > + explicit SCEVConstant(ConstantInt *v, const ScalarEvolution* p) : > + SCEV(scConstant, p), V(v) {} > > virtual ~SCEVConstant(); > public: > @@ -79,7 +80,8 @@ > SCEVHandle Op; > const Type *Ty; > > - SCEVCastExpr(unsigned SCEVTy, const SCEVHandle &op, const Type *ty); > + SCEVCastExpr(unsigned SCEVTy, const SCEVHandle &op, const Type *ty, > + const ScalarEvolution* p); > virtual ~SCEVCastExpr(); > > public: > @@ -112,7 +114,8 @@ > class SCEVTruncateExpr : public SCEVCastExpr { > friend class ScalarEvolution; > > - SCEVTruncateExpr(const SCEVHandle &op, const Type *ty); > + SCEVTruncateExpr(const SCEVHandle &op, const Type *ty, > + const ScalarEvolution* p); > virtual ~SCEVTruncateExpr(); > > public: > @@ -141,7 +144,8 @@ > class SCEVZeroExtendExpr : public SCEVCastExpr { > friend class ScalarEvolution; > > - SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty); > + SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty, > + const ScalarEvolution* p); > virtual ~SCEVZeroExtendExpr(); > > public: > @@ -170,7 +174,8 @@ > class SCEVSignExtendExpr : public SCEVCastExpr { > friend class ScalarEvolution; > > - SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty); > + SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty, > + const ScalarEvolution* p); > virtual ~SCEVSignExtendExpr(); > > public: > @@ -201,8 +206,9 @@ > protected: > SmallVector Operands; > > - SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl &ops) > - : SCEV(T), Operands(ops.begin(), ops.end()) {} > + SCEVNAryExpr(enum SCEVTypes T, const SmallVectorImpl &ops, > + const ScalarEvolution* p) > + : SCEV(T, p), Operands(ops.begin(), ops.end()) {} > virtual ~SCEVNAryExpr() {} > > public: > @@ -259,8 +265,10 @@ > /// > class SCEVCommutativeExpr : public SCEVNAryExpr { > protected: > - SCEVCommutativeExpr(enum SCEVTypes T, const SmallVectorImpl &ops) > - : SCEVNAryExpr(T, ops) {} > + SCEVCommutativeExpr(enum SCEVTypes T, > + const SmallVectorImpl &ops, > + const ScalarEvolution* p) > + : SCEVNAryExpr(T, ops, p) {} > ~SCEVCommutativeExpr(); > > public: > @@ -289,8 +297,9 @@ > class SCEVAddExpr : public SCEVCommutativeExpr { > friend class ScalarEvolution; > > - explicit SCEVAddExpr(const SmallVectorImpl &ops) > - : SCEVCommutativeExpr(scAddExpr, ops) { > + explicit SCEVAddExpr(const SmallVectorImpl &ops, > + const ScalarEvolution* p) > + : SCEVCommutativeExpr(scAddExpr, ops, p) { > } > > public: > @@ -309,8 +318,9 @@ > class SCEVMulExpr : public SCEVCommutativeExpr { > friend class ScalarEvolution; > > - explicit SCEVMulExpr(const SmallVectorImpl &ops) > - : SCEVCommutativeExpr(scMulExpr, ops) { > + explicit SCEVMulExpr(const SmallVectorImpl &ops, > + const ScalarEvolution* p) > + : SCEVCommutativeExpr(scMulExpr, ops, p) { > } > > public: > @@ -331,8 +341,9 @@ > friend class ScalarEvolution; > > SCEVHandle LHS, RHS; > - SCEVUDivExpr(const SCEVHandle &lhs, const SCEVHandle &rhs) > - : SCEV(scUDivExpr), LHS(lhs), RHS(rhs) {} > + SCEVUDivExpr(const SCEVHandle &lhs, const SCEVHandle &rhs, > + const ScalarEvolution* p) > + : SCEV(scUDivExpr, p), LHS(lhs), RHS(rhs) {} > > virtual ~SCEVUDivExpr(); > public: > @@ -387,8 +398,9 @@ > > const Loop *L; > > - SCEVAddRecExpr(const SmallVectorImpl &ops, const Loop *l) > - : SCEVNAryExpr(scAddRecExpr, ops), L(l) { > + SCEVAddRecExpr(const SmallVectorImpl &ops, const Loop *l, > + const ScalarEvolution* p) > + : SCEVNAryExpr(scAddRecExpr, ops, p), L(l) { > for (size_t i = 0, e = Operands.size(); i != e; ++i) > assert(Operands[i]->isLoopInvariant(l) && > "Operands of AddRec must be loop-invariant!"); > @@ -463,8 +475,9 @@ > class SCEVSMaxExpr : public SCEVCommutativeExpr { > friend class ScalarEvolution; > > - explicit SCEVSMaxExpr(const SmallVectorImpl &ops) > - : SCEVCommutativeExpr(scSMaxExpr, ops) { > + explicit SCEVSMaxExpr(const SmallVectorImpl &ops, > + const ScalarEvolution* p) > + : SCEVCommutativeExpr(scSMaxExpr, ops, p) { > } > > public: > @@ -484,8 +497,9 @@ > class SCEVUMaxExpr : public SCEVCommutativeExpr { > friend class ScalarEvolution; > > - explicit SCEVUMaxExpr(const SmallVectorImpl &ops) > - : SCEVCommutativeExpr(scUMaxExpr, ops) { > + explicit SCEVUMaxExpr(const SmallVectorImpl &ops, > + const ScalarEvolution* p) > + : SCEVCommutativeExpr(scUMaxExpr, ops, p) { > } > > public: > @@ -508,7 +522,8 @@ > friend class ScalarEvolution; > > Value *V; > - explicit SCEVUnknown(Value *v) : SCEV(scUnknown), V(v) {} > + explicit SCEVUnknown(Value *v, const ScalarEvolution* p) : > + SCEV(scUnknown, p), V(v) {} > > protected: > ~SCEVUnknown(); > > Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=73728&r1=73727&r2=73728&view=diff > > ============================================================================== > --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) > +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Jun 18 17:25:12 2009 > @@ -133,7 +133,8 @@ > return false; > } > > -SCEVCouldNotCompute::SCEVCouldNotCompute() : SCEV(scCouldNotCompute) {} > +SCEVCouldNotCompute::SCEVCouldNotCompute(const ScalarEvolution* p) : > + SCEV(scCouldNotCompute, p) {} > SCEVCouldNotCompute::~SCEVCouldNotCompute() {} > > bool SCEVCouldNotCompute::isLoopInvariant(const Loop *L) const { > @@ -179,7 +180,7 @@ > > SCEVHandle ScalarEvolution::getConstant(ConstantInt *V) { > SCEVConstant *&R = (*SCEVConstants)[V]; > - if (R == 0) R = new SCEVConstant(V); > + if (R == 0) R = new SCEVConstant(V, this); > return R; > } > > @@ -199,8 +200,9 @@ > } > > SCEVCastExpr::SCEVCastExpr(unsigned SCEVTy, > - const SCEVHandle &op, const Type *ty) > - : SCEV(SCEVTy), Op(op), Ty(ty) {} > + const SCEVHandle &op, const Type *ty, > + const ScalarEvolution* p) > + : SCEV(SCEVTy, p), Op(op), Ty(ty) {} > > SCEVCastExpr::~SCEVCastExpr() {} > > @@ -214,8 +216,9 @@ > static ManagedStatic, > SCEVTruncateExpr*> > SCEVTruncates; > > -SCEVTruncateExpr::SCEVTruncateExpr(const SCEVHandle &op, const Type *ty) > - : SCEVCastExpr(scTruncate, op, ty) { > +SCEVTruncateExpr::SCEVTruncateExpr(const SCEVHandle &op, const Type *ty, > + const ScalarEvolution* p) > + : SCEVCastExpr(scTruncate, op, ty, p) { > assert((Op->getType()->isInteger() || isa(Op->getType())) && > (Ty->isInteger() || isa(Ty)) && > "Cannot truncate non-integer value!"); > @@ -235,8 +238,9 @@ > static ManagedStatic, > SCEVZeroExtendExpr*> > SCEVZeroExtends; > > -SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty) > - : SCEVCastExpr(scZeroExtend, op, ty) { > +SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty, > + const ScalarEvolution* p) > + : SCEVCastExpr(scZeroExtend, op, ty, p) { > assert((Op->getType()->isInteger() || isa(Op->getType())) && > (Ty->isInteger() || isa(Ty)) && > "Cannot zero extend non-integer value!"); > @@ -256,8 +260,9 @@ > static ManagedStatic, > SCEVSignExtendExpr*> > SCEVSignExtends; > > -SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty) > - : SCEVCastExpr(scSignExtend, op, ty) { > +SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty, > + const ScalarEvolution* p) > + : SCEVCastExpr(scSignExtend, op, ty, p) { > assert((Op->getType()->isInteger() || isa(Op->getType())) && > (Ty->isInteger() || isa(Ty)) && > "Cannot sign extend non-integer value!"); > @@ -787,7 +792,7 @@ > } > > SCEVTruncateExpr *&Result = (*SCEVTruncates)[std::make_pair(Op, Ty)]; > - if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty); > + if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty, this); > return Result; > } > > @@ -875,7 +880,7 @@ > } > > SCEVZeroExtendExpr *&Result = (*SCEVZeroExtends)[std::make_pair(Op, Ty)]; > - if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty); > + if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty, this); > return Result; > } > > @@ -947,7 +952,7 @@ > } > > SCEVSignExtendExpr *&Result = (*SCEVSignExtends)[std::make_pair(Op, Ty)]; > - if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty); > + if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty, this); > return Result; > } > > @@ -1409,7 +1414,7 @@ > std::vector SCEVOps(Ops.begin(), Ops.end()); > SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scAddExpr, > SCEVOps)]; > - if (Result == 0) Result = new SCEVAddExpr(Ops); > + if (Result == 0) Result = new SCEVAddExpr(Ops, this); > return Result; > } > > @@ -1575,7 +1580,7 @@ > SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scMulExpr, > SCEVOps)]; > if (Result == 0) > - Result = new SCEVMulExpr(Ops); > + Result = new SCEVMulExpr(Ops, this); > return Result; > } > > @@ -1666,7 +1671,7 @@ > } > > SCEVUDivExpr *&Result = (*SCEVUDivs)[std::make_pair(LHS, RHS)]; > - if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS); > + if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS, this); > return Result; > } > > @@ -1720,7 +1725,7 @@ > > std::vector SCEVOps(Operands.begin(), Operands.end()); > SCEVAddRecExpr *&Result = (*SCEVAddRecExprs)[std::make_pair(L, SCEVOps)]; > - if (Result == 0) Result = new SCEVAddRecExpr(Operands, L); > + if (Result == 0) Result = new SCEVAddRecExpr(Operands, L, this); > return Result; > } > > @@ -1807,7 +1812,7 @@ > std::vector SCEVOps(Ops.begin(), Ops.end()); > SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scSMaxExpr, > SCEVOps)]; > - if (Result == 0) Result = new SCEVSMaxExpr(Ops); > + if (Result == 0) Result = new SCEVSMaxExpr(Ops, this); > return Result; > } > > @@ -1894,7 +1899,7 @@ > std::vector SCEVOps(Ops.begin(), Ops.end()); > SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scUMaxExpr, > SCEVOps)]; > - if (Result == 0) Result = new SCEVUMaxExpr(Ops); > + if (Result == 0) Result = new SCEVUMaxExpr(Ops, this); > return Result; > } > > @@ -1904,7 +1909,7 @@ > if (isa(V)) > return getIntegerSCEV(0, V->getType()); > SCEVUnknown *&Result = (*SCEVUnknowns)[V]; > - if (Result == 0) Result = new SCEVUnknown(V); > + if (Result == 0) Result = new SCEVUnknown(V, this); > return Result; > } > > @@ -3978,7 +3983,7 @@ > //===----------------------------------------------------------------------===// > > ScalarEvolution::ScalarEvolution() > - : FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute()) { > + : FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute(0)) { > } > > bool ScalarEvolution::runOnFunction(Function &F) { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From lhames at gmail.com Thu Jun 18 21:17:53 2009 From: lhames at gmail.com (Lang Hames) Date: Fri, 19 Jun 2009 02:17:53 -0000 Subject: [llvm-commits] [llvm] r73750 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/Spiller.cpp lib/CodeGen/Spiller.h Message-ID: <200906190217.n5J2HsZ9001181@zion.cs.uiuc.edu> Author: lhames Date: Thu Jun 18 21:17:53 2009 New Revision: 73750 URL: http://llvm.org/viewvc/llvm-project?rev=73750&view=rev Log: More VNInfo tweaking, plus a little progress on intra-block splitting. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/Spiller.cpp llvm/trunk/lib/CodeGen/Spiller.h Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=73750&r1=73749&r2=73750&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Thu Jun 18 21:17:53 2009 @@ -40,14 +40,14 @@ /// Care must be taken in interpreting the def index of the value. The /// following rules apply: /// - /// If the isDefAccurate() method returns false then the def index does not - /// actually point to the defining MachineInstr, or even (necessarily) a - /// valid MachineInstr at all. In general such a def index should not be - /// used as an index to obtain a MachineInstr. The exception is Values - /// defined by PHI instructions, after PHI elimination has occured. In this - /// case the def should point to the start of the block in which the PHI - /// existed. This fact can be used to insert code dealing with the PHI value - /// at the merge point (e.g. to spill or split it). + /// If the isDefAccurate() method returns false then def does not contain the + /// index of the defining MachineInstr, or even (necessarily) to a + /// MachineInstr at all. In general such a def index is not meaningful + /// and should not be used. The exception is that, for values originally + /// defined by PHI instructions, after PHI elimination def will contain the + /// index of the MBB in which the PHI originally existed. This can be used + /// to insert code (spills or copies) which deals with the value, which will + /// be live in to the block. class VNInfo { private: Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=73750&r1=73749&r2=73750&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Jun 18 21:17:53 2009 @@ -584,7 +584,8 @@ // Replace the interval with one of a NEW value number. Note that this // value number isn't actually defined by an instruction, weird huh? :) - LiveRange LR(Start, End, interval.getNextValue(Start, 0, false, VNInfoAllocator)); + LiveRange LR(Start, End, + interval.getNextValue(mbb->getNumber(), 0, false, VNInfoAllocator)); LR.valno->setIsPHIDef(true); DOUT << " replace range with " << LR; interval.addRange(LR); @@ -785,7 +786,8 @@ } } - VNInfo *vni = interval.getNextValue(start, 0, false, VNInfoAllocator); + VNInfo *vni = + interval.getNextValue(MBB->getNumber(), 0, false, VNInfoAllocator); vni->setIsPHIDef(true); LiveRange LR(start, end, vni); Modified: llvm/trunk/lib/CodeGen/Spiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.cpp?rev=73750&r1=73749&r2=73750&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.cpp (original) +++ llvm/trunk/lib/CodeGen/Spiller.cpp Thu Jun 18 21:17:53 2009 @@ -39,7 +39,8 @@ VirtRegMap *vrm; /// Construct a spiller base. - SpillerBase(MachineFunction *mf, LiveIntervals *lis, LiveStacks *ls, VirtRegMap *vrm) : + SpillerBase(MachineFunction *mf, LiveIntervals *lis, LiveStacks *ls, + VirtRegMap *vrm) : mf(mf), lis(lis), ls(ls), vrm(vrm) { mfi = mf->getFrameInfo(); @@ -85,6 +86,7 @@ unsigned insertStoreFor(MachineInstr *mi, unsigned ss, unsigned vreg, const TargetRegisterClass *trc) { + MachineBasicBlock::iterator nextInstItr(mi); ++nextInstItr; @@ -105,6 +107,23 @@ return storeInstIdx; } + void insertStoreOnInterval(LiveInterval *li, + MachineInstr *mi, unsigned ss, + unsigned vreg, + const TargetRegisterClass *trc) { + + unsigned storeInstIdx = insertStoreFor(mi, ss, vreg, trc); + unsigned start = lis->getDefIndex(lis->getInstructionIndex(mi)), + end = lis->getUseIndex(storeInstIdx); + + VNInfo *vni = + li->getNextValue(storeInstIdx, 0, true, lis->getVNInfoAllocator()); + vni->kills.push_back(storeInstIdx); + LiveRange lr(start, end, vni); + + li->addRange(lr); + } + /// Insert a load of the given veg from the given stack slot immediately /// before the given instruction. Returns the base index of the inserted /// instruction. The caller is responsible for adding an appropriate @@ -130,6 +149,25 @@ return loadInstIdx; } + void insertLoadOnInterval(LiveInterval *li, + MachineInstr *mi, unsigned ss, + unsigned vreg, + const TargetRegisterClass *trc) { + + unsigned loadInstIdx = insertLoadFor(mi, ss, vreg, trc); + unsigned start = lis->getDefIndex(loadInstIdx), + end = lis->getUseIndex(lis->getInstructionIndex(mi)); + + VNInfo *vni = + li->getNextValue(loadInstIdx, 0, true, lis->getVNInfoAllocator()); + vni->kills.push_back(lis->getInstructionIndex(mi)); + LiveRange lr(start, end, vni); + + li->addRange(lr); + } + + + /// Add spill ranges for every use/def of the live interval, inserting loads /// immediately before each use, and stores after each def. No folding is /// attempted. @@ -189,29 +227,11 @@ assert(hasUse || hasDef); if (hasUse) { - unsigned loadInstIdx = insertLoadFor(mi, ss, newVReg, trc); - unsigned start = lis->getDefIndex(loadInstIdx), - end = lis->getUseIndex(lis->getInstructionIndex(mi)); - - VNInfo *vni = - newLI->getNextValue(loadInstIdx, 0, true, lis->getVNInfoAllocator()); - vni->kills.push_back(lis->getInstructionIndex(mi)); - LiveRange lr(start, end, vni); - - newLI->addRange(lr); + insertLoadOnInterval(newLI, mi, ss, newVReg, trc); } if (hasDef) { - unsigned storeInstIdx = insertStoreFor(mi, ss, newVReg, trc); - unsigned start = lis->getDefIndex(lis->getInstructionIndex(mi)), - end = lis->getUseIndex(storeInstIdx); - - VNInfo *vni = - newLI->getNextValue(storeInstIdx, 0, true, lis->getVNInfoAllocator()); - vni->kills.push_back(storeInstIdx); - LiveRange lr(start, end, vni); - - newLI->addRange(lr); + insertStoreOnInterval(newLI, mi, ss, newVReg, trc); } added.push_back(newLI); @@ -227,13 +247,44 @@ /// folding. class TrivialSpiller : public SpillerBase { public: - TrivialSpiller(MachineFunction *mf, LiveIntervals *lis, LiveStacks *ls, VirtRegMap *vrm) : + + TrivialSpiller(MachineFunction *mf, LiveIntervals *lis, LiveStacks *ls, + VirtRegMap *vrm) : SpillerBase(mf, lis, ls, vrm) {} std::vector spill(LiveInterval *li) { return trivialSpillEverywhere(li); } + std::vector intraBlockSplit(LiveInterval *li, VNInfo *valno) { + std::vector spillIntervals; + MachineBasicBlock::iterator storeInsertPoint; + + if (valno->isDefAccurate()) { + // If we have an accurate def we can just grab an iterator to the instr + // after the def. + storeInsertPoint = + next(MachineBasicBlock::iterator(lis->getInstructionFromIndex(valno->def))); + } else { + // If the def info isn't accurate we check if this is a PHI def. + // If it is then def holds the index of the defining Basic Block, and we + // can use that to get an insertion point. + if (valno->isPHIDef()) { + + } else { + // We have no usable def info. We can't split this value sensibly. + // FIXME: Need sensible feedback for "failure to split", an empty + // set of spill intervals could be reasonably returned from a + // split where both the store and load are folded. + return spillIntervals; + } + } + + + + return spillIntervals; + } + }; } Modified: llvm/trunk/lib/CodeGen/Spiller.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.h?rev=73750&r1=73749&r2=73750&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.h (original) +++ llvm/trunk/lib/CodeGen/Spiller.h Thu Jun 18 21:17:53 2009 @@ -13,12 +13,14 @@ #include namespace llvm { + class LiveInterval; class LiveIntervals; class LiveStacks; class MachineFunction; - class VirtRegMap; class MachineInstr; + class VirtRegMap; + class VNInfo; /// Spiller interface. /// @@ -32,6 +34,10 @@ /// implementation selected. virtual std::vector spill(LiveInterval *li) = 0; + /// Intra-block split. + virtual std::vector intraBlockSplit(LiveInterval *li, + VNInfo *valno) = 0; + }; /// Create and return a spiller object, as specified on the command line. From sanjiv.gupta at microchip.com Thu Jun 18 22:49:23 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Fri, 19 Jun 2009 09:19:23 +0530 Subject: [llvm-commits] [llvm] r73401 - /llvm/trunk/lib/Analysis/IVUsers.cpp In-Reply-To: References: <200906151838.n5FIcxns002287@zion.cs.uiuc.edu> <4A39F352.9090003@microchip.com> Message-ID: <4A3B0AC3.2060509@microchip.com> >>> >>> >>> + AddRecStart = SE->getSCEVAtScope(AddRecStart, UseLoop); >>> >>> + SCEVHandle AddRecStride = AddRec->getStepRecurrence(*SE); >>> >>> + AddRecStride = SE->getSCEVAtScope(AddRecStride, UseLoop); >>> >>> >>> >> Dan, >> >> Since you meant only code cleanup, the last line I think is left >> there by mistake as in the original code we had only one call to >> >> SE->getSCEVAtScope(AddRecStart, UseLoop); which is already there two >> lines above. > > Hmm, you're right that this wasn't pure cleanup. This commit is a > change I had split out from a larger patch, and I missed that detail. > The call isn't redundant though; the first call is doing getSCEVAtScope > for the Start expression, and the second is doing it for the Stride > expression. This probably isn't especially valuable at the moment, > but it shouldn't cause trouble. > > Dan > It is causing trouble. Few of our test cases broke. They run fine if I remove the last call though. - Sanjiv From sabre at nondot.org Thu Jun 18 23:17:36 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Jun 2009 04:17:36 -0000 Subject: [llvm-commits] [llvm] r73751 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll Message-ID: <200906190417.n5J4HbFO006638@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 23:17:36 2009 New Revision: 73751 URL: http://llvm.org/viewvc/llvm-project?rev=73751&view=rev Log: part of PR4405: disable a contentious optimization for strcmp -> memcmp when the lengths of the strings are unknown. Patch by Nick Lewycky! Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=73751&r1=73750&r2=73751&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu Jun 18 23:17:36 2009 @@ -709,12 +709,10 @@ // strcmp(P, "x") -> memcmp(P, "x", 2) uint64_t Len1 = GetStringLength(Str1P); uint64_t Len2 = GetStringLength(Str2P); - if (Len1 || Len2) { - // Choose the smallest Len excluding 0 which means 'unknown'. - if (!Len1 || (Len2 && Len2 < Len1)) - Len1 = Len2; + if (Len1 && Len2) { return EmitMemCmp(Str1P, Str2P, - ConstantInt::get(TD->getIntPtrType(), Len1), B); + ConstantInt::get(TD->getIntPtrType(), + std::min(Len1, Len2)), B); } return 0; Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll?rev=73750&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll (removed) @@ -1,10 +0,0 @@ -; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | grep call.*memcmp - - at .str = internal constant [2 x i8] c"x\00" - -declare i32 @strcmp(i8* %dest, i8* %src) - -define i32 @foo(i8* %x, i8* %y) { - %A = call i32 @strcmp(i8* %x, i8* getelementptr ([2 x i8]* @.str, i32 0, i32 0)) - ret i32 %A -} From sabre at nondot.org Thu Jun 18 23:22:17 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Jun 2009 04:22:17 -0000 Subject: [llvm-commits] [llvm] r73752 - in /llvm/trunk: lib/Transforms/Scalar/TailRecursionElimination.cpp test/Transforms/TailCallElim/dont_reorder_load.ll test/Transforms/TailCallElim/reorder_load.ll Message-ID: <200906190422.n5J4MHc6007007@zion.cs.uiuc.edu> Author: lattner Date: Thu Jun 18 23:22:16 2009 New Revision: 73752 URL: http://llvm.org/viewvc/llvm-project?rev=73752&view=rev Log: Improve tail call elim to move loads above readonly calls when it allows forming a tail call. Patch by Frits van Bommel. This implements PR4323. Added: llvm/trunk/test/Transforms/TailCallElim/dont_reorder_load.ll llvm/trunk/test/Transforms/TailCallElim/reorder_load.ll 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=73752&r1=73751&r2=73752&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Thu Jun 18 23:22:16 2009 @@ -52,6 +52,7 @@ #define DEBUG_TYPE "tailcallelim" #include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Utils/Local.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Function.h" @@ -201,8 +202,21 @@ bool TailCallElim::CanMoveAboveCall(Instruction *I, CallInst *CI) { // FIXME: We can move load/store/call/free instructions above the call if the // call does not mod/ref the memory location being processed. - if (I->mayHaveSideEffects() || isa(I)) + if (I->mayHaveSideEffects()) // This also handles volatile loads. return false; + + if (LoadInst* L = dyn_cast(I)) { + // Loads may always be moved above calls without side effects. + if (CI->mayHaveSideEffects()) { + // Non-volatile loads may be moved above a call with side effects if it + // does not write to memory and the load provably won't trap. + // FIXME: Writes to memory only matter if they may alias the pointer + // being loaded from. + if (CI->mayWriteToMemory() || + !isSafeToLoadUnconditionally(L->getPointerOperand(), L)) + return false; + } + } // Otherwise, if this is a side-effect free instruction, check to make sure // that it does not use the return value of the call. If it doesn't use the Added: llvm/trunk/test/Transforms/TailCallElim/dont_reorder_load.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailCallElim/dont_reorder_load.ll?rev=73752&view=auto ============================================================================== --- llvm/trunk/test/Transforms/TailCallElim/dont_reorder_load.ll (added) +++ llvm/trunk/test/Transforms/TailCallElim/dont_reorder_load.ll Thu Jun 18 23:22:16 2009 @@ -0,0 +1,64 @@ +; RUN: llvm-as <%s | opt -tailcallelim | llvm-dis | grep call | count 3 +; PR4323 + +; Several cases where tail call elimination should not move the load above the +; call, and thus can't eliminate the tail recursion. + + + at extern_weak_global = extern_weak global i32 ; [#uses=1] + + +; This load can't be safely moved above the call because the load is from an +; extern_weak global and may trap, but the call may unwind before that happens. +define fastcc i32 @no_tailrecelim_1(i32* %a_arg, i32 %a_len_arg, i32 %start_arg) readonly { +entry: + %tmp2 = icmp sge i32 %start_arg, %a_len_arg ; [#uses=1] + br i1 %tmp2, label %if, label %else + +if: ; preds = %entry + unwind + +else: ; preds = %entry + %tmp7 = add i32 %start_arg, 1 ; [#uses=1] + %tmp8 = call fastcc i32 @no_tailrecelim_1(i32* %a_arg, i32 %a_len_arg, i32 %tmp7) ; [#uses=1] + %tmp9 = load i32* @extern_weak_global ; [#uses=1] + %tmp10 = add i32 %tmp9, %tmp8 ; [#uses=1] + ret i32 %tmp10 +} + + +; This load can't be safely moved above the call because function may write to the pointer. +define fastcc i32 @no_tailrecelim_2(i32* %a_arg, i32 %a_len_arg, i32 %start_arg) nounwind { +entry: + %tmp2 = icmp sge i32 %start_arg, %a_len_arg ; [#uses=1] + br i1 %tmp2, label %if, label %else + +if: ; preds = %entry + store i32 1, i32* %a_arg; + ret i32 0; + +else: ; preds = %entry + %tmp7 = add i32 %start_arg, 1 ; [#uses=1] + %tmp8 = call fastcc i32 @no_tailrecelim_2(i32* %a_arg, i32 %a_len_arg, i32 %tmp7) ; [#uses=1] + %tmp9 = load i32* %a_arg ; [#uses=1] + %tmp10 = add i32 %tmp9, %tmp8 ; [#uses=1] + ret i32 %tmp10 +} + +; This load can't be safely moved above the call because that would change the +; order in which the volatile loads are performed. +define fastcc i32 @no_tailrecelim_3(i32* %a_arg, i32 %a_len_arg, i32 %start_arg) nounwind { +entry: + %tmp2 = icmp sge i32 %start_arg, %a_len_arg ; [#uses=1] + br i1 %tmp2, label %if, label %else + +if: ; preds = %entry + ret i32 0; + +else: ; preds = %entry + %tmp7 = add i32 %start_arg, 1 ; [#uses=1] + %tmp8 = call fastcc i32 @no_tailrecelim_3(i32* %a_arg, i32 %a_len_arg, i32 %tmp7) ; [#uses=1] + %tmp9 = volatile load i32* %a_arg ; [#uses=1] + %tmp10 = add i32 %tmp9, %tmp8 ; [#uses=1] + ret i32 %tmp10 +} Added: llvm/trunk/test/Transforms/TailCallElim/reorder_load.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailCallElim/reorder_load.ll?rev=73752&view=auto ============================================================================== --- llvm/trunk/test/Transforms/TailCallElim/reorder_load.ll (added) +++ llvm/trunk/test/Transforms/TailCallElim/reorder_load.ll Thu Jun 18 23:22:16 2009 @@ -0,0 +1,101 @@ +; RUN: llvm-as <%s | opt -tailcallelim | llvm-dis | not grep call +; PR4323 + +; Several cases where tail call elimination should move the load above the call, +; then eliminate the tail recursion. + + + at global = external global i32 ; [#uses=1] + at extern_weak_global = extern_weak global i32 ; [#uses=1] + + +; This load can be moved above the call because the function won't write to it +; and the call has no side effects. +define fastcc i32 @raise_load_1(i32* %a_arg, i32 %a_len_arg, i32 %start_arg) nounwind readonly { +entry: + %tmp2 = icmp sge i32 %start_arg, %a_len_arg ; [#uses=1] + br i1 %tmp2, label %if, label %else + +if: ; preds = %entry + ret i32 0 + +else: ; preds = %entry + %tmp7 = add i32 %start_arg, 1 ; [#uses=1] + %tmp8 = call fastcc i32 @raise_load_1(i32* %a_arg, i32 %a_len_arg, i32 %tmp7) ; [#uses=1] + %tmp9 = load i32* %a_arg ; [#uses=1] + %tmp10 = add i32 %tmp9, %tmp8 ; [#uses=1] + ret i32 %tmp10 +} + + +; This load can be moved above the call because the function won't write to it +; and the load provably can't trap. +define fastcc i32 @raise_load_2(i32* %a_arg, i32 %a_len_arg, i32 %start_arg) readonly { +entry: + %tmp2 = icmp sge i32 %start_arg, %a_len_arg ; [#uses=1] + br i1 %tmp2, label %if, label %else + +if: ; preds = %entry + ret i32 0 + +else: ; preds = %entry + %nullcheck = icmp eq i32* %a_arg, null ; [#uses=1] + br i1 %nullcheck, label %unwind, label %recurse + +unwind: ; preds = %else + unwind + +recurse: ; preds = %else + %tmp7 = add i32 %start_arg, 1 ; [#uses=1] + %tmp8 = call fastcc i32 @raise_load_2(i32* %a_arg, i32 %a_len_arg, i32 %tmp7) ; [#uses=1] + %tmp9 = load i32* @global ; [#uses=1] + %tmp10 = add i32 %tmp9, %tmp8 ; [#uses=1] + ret i32 %tmp10 +} + + +; This load can be safely moved above the call (even though it's from an +; extern_weak global) because the call has no side effects. +define fastcc i32 @raise_load_3(i32* %a_arg, i32 %a_len_arg, i32 %start_arg) nounwind readonly { +entry: + %tmp2 = icmp sge i32 %start_arg, %a_len_arg ; [#uses=1] + br i1 %tmp2, label %if, label %else + +if: ; preds = %entry + ret i32 0 + +else: ; preds = %entry + %tmp7 = add i32 %start_arg, 1 ; [#uses=1] + %tmp8 = call fastcc i32 @raise_load_3(i32* %a_arg, i32 %a_len_arg, i32 %tmp7) ; [#uses=1] + %tmp9 = load i32* @extern_weak_global ; [#uses=1] + %tmp10 = add i32 %tmp9, %tmp8 ; [#uses=1] + ret i32 %tmp10 +} + + +; The second load can be safely moved above the call even though it's from an +; unknown pointer (which normally means it might trap) because the first load +; proves it doesn't trap. +define fastcc i32 @raise_load_4(i32* %a_arg, i32 %a_len_arg, i32 %start_arg) readonly { +entry: + %tmp2 = icmp sge i32 %start_arg, %a_len_arg ; [#uses=1] + br i1 %tmp2, label %if, label %else + +if: ; preds = %entry + ret i32 0 + +else: ; preds = %entry + %nullcheck = icmp eq i32* %a_arg, null ; [#uses=1] + br i1 %nullcheck, label %unwind, label %recurse + +unwind: ; preds = %else + unwind + +recurse: ; preds = %else + %tmp7 = add i32 %start_arg, 1 ; [#uses=1] + %first = load i32* %a_arg ; [#uses=1] + %tmp8 = call fastcc i32 @raise_load_4(i32* %a_arg, i32 %first, i32 %tmp7) ; [#uses=1] + %second = load i32* %a_arg ; [#uses=1] + %tmp10 = add i32 %second, %tmp8 ; [#uses=1] + ret i32 %tmp10 +} From clattner at apple.com Thu Jun 18 23:22:55 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 18 Jun 2009 21:22:55 -0700 Subject: [llvm-commits] [PATCH] Tail recursion elimination and memory loads. In-Reply-To: <4A380565.5050203@wxs.nl> References: <4A380565.5050203@wxs.nl> Message-ID: On Jun 16, 2009, at 1:49 PM, Frits van Bommel wrote: > When tail recursion elimination (opt -tailcallelim) sees other > instructions between the recursive call and the return instruction, > it tries to figure out if it's safe to move them above the call > (putting the call in tail position). > > However, it refuses to do that for load instructions after the call. > The attached patch checks for some conditions in which it is safe to > do this for loads as well. > > There are two basic cases: > 1) The call has no side-effects, in which case it's always safe > since the load would happen anyway and it shouldn't matter if it's > done a bit sooner. > 2) The load is non-volatile, the call does not write to memory, and > the pointer isSafeToLoadUnconditionally() at that point in the code. > In this case, the load has no side-effects (and won't trap) and the > memory it loads from won't contain different data after the call, > making it safe to raise the load above the call. Looks great, applied here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090615/079051.html Note that volatile loads return true for "may write to memory" so they don't need special handling, Thanks Frits! -Chris From clattner at apple.com Thu Jun 18 23:34:15 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 18 Jun 2009 21:34:15 -0700 Subject: [llvm-commits] teach jump-threading to handle br(icmp against non-constants) In-Reply-To: <4A39EA1B.3080507@mxc.ca> References: <4A39EA1B.3080507@mxc.ca> Message-ID: <3B30F6BD-5D82-4263-B19F-ED49240A7A92@apple.com> On Jun 18, 2009, at 12:17 AM, Nick Lewycky wrote: > The attached patch teaches jump threading to handle the case where a > PHI node is compared against an element inside the PHI node. > Please review! The patch looks great, please apply with these changes: 1. Please rename resultOfComparison to something like GetResultOfComparison. 2. Please add a doxygen comment describing what the operands are and what it does. Thanks for working on this. If you're interested, there are a ton of similar improvements that we can make to jump threading. -Chris > > There are still a couple of related optimizations this is missing: > 1. we could create FCmpInst::isFalseWhenEqual and use that to > handle some of the equivalent cases for float. Note that "true when > equal" is not well defined for floats thanks to NaNs, but false > should be fine. > 2. we could handle this: > > jt: > %x = phi i8 [%a, %bb1], [0, %bb2] > %A = icmp ugt i8 %x, %b > br i1 %A, label %rt, label %rf > > if we realized that "icmp ult i8 0, %b" is never true. There's a > small battery of related tests. > > If someone does implement the above extensions, it would probably > make sense to factor out "resultOfComparison" and put it somewhere > more generally useful. Instcombine does these too, for example. > > Nick > > _______________________________________________ > 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 Thu Jun 18 23:48:39 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 19 Jun 2009 04:48:39 -0000 Subject: [llvm-commits] [llvm] r73753 - in /llvm/trunk/lib/Target/X86: AsmPrinter/X86IntelAsmPrinter.cpp X86InstrInfo.td X86TargetAsmInfo.cpp Message-ID: <200906190448.n5J4mdTS008302@zion.cs.uiuc.edu> Author: efriedma Date: Thu Jun 18 23:48:38 2009 New Revision: 73753 URL: http://llvm.org/viewvc/llvm-project?rev=73753&view=rev Log: Misc tweaks to Intel asm printing to make it more compatible with MASM. Patch by Benedict Gaster. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp?rev=73753&r1=73752&r2=73753&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Thu Jun 18 23:48:38 2009 @@ -339,8 +339,8 @@ } void X86IntelAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) { - O << "\"L" << getFunctionNumber() << "$pb\"\n"; - O << "\"L" << getFunctionNumber() << "$pb\":"; + O << "L" << getFunctionNumber() << "$pb\n"; + O << "L" << getFunctionNumber() << "$pb:"; } bool X86IntelAsmPrinter::printAsmMRegister(const MachineOperand &MO, @@ -362,7 +362,7 @@ break; } - O << '%' << TRI->getName(Reg); + O << TRI->getName(Reg); return false; } @@ -414,7 +414,7 @@ Mang->markCharUnacceptable('.'); - O << "\t.686\n\t.model flat\n\n"; + O << "\t.686\n\t.MMX\n\t.XMM\n\t.model flat\n\n"; // Emit declarations for external functions. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) @@ -422,7 +422,7 @@ std::string Name = Mang->getValueName(I); decorateName(Name, I); - O << "\textern " ; + O << "\tEXTERN " ; if (I->hasDLLImportLinkage()) { O << "__imp_"; } @@ -436,7 +436,7 @@ if (I->isDeclaration()) { std::string Name = Mang->getValueName(I); - O << "\textern " ; + O << "\tEXTERN " ; if (I->hasDLLImportLinkage()) { O << "__imp_"; } @@ -471,14 +471,14 @@ case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakODRLinkage: SwitchToDataSection(""); - O << name << "?\tsegment common 'COMMON'\n"; + O << name << "?\tSEGEMNT PARA common 'COMMON'\n"; bCustomSegment = true; // FIXME: the default alignment is 16 bytes, but 1, 2, 4, and 256 // are also available. break; case GlobalValue::AppendingLinkage: SwitchToDataSection(""); - O << name << "?\tsegment public 'DATA'\n"; + O << name << "?\tSEGMENT PARA public 'DATA'\n"; bCustomSegment = true; // FIXME: the default alignment is 16 bytes, but 1, 2, 4, and 256 // are also available. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=73753&r1=73752&r2=73753&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Thu Jun 18 23:48:38 2009 @@ -1735,13 +1735,13 @@ let Defs = [EFLAGS] in { let Uses = [CL] in { def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src), - "shl{b}\t{%cl, $dst|$dst, %CL}", + "shl{b}\t{%cl, $dst|$dst, CL}", [(set GR8:$dst, (shl GR8:$src, CL))]>; def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src), - "shl{w}\t{%cl, $dst|$dst, %CL}", + "shl{w}\t{%cl, $dst|$dst, CL}", [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize; def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src), - "shl{l}\t{%cl, $dst|$dst, %CL}", + "shl{l}\t{%cl, $dst|$dst, CL}", [(set GR32:$dst, (shl GR32:$src, CL))]>; } // Uses = [CL] @@ -1762,13 +1762,13 @@ let isTwoAddress = 0 in { let Uses = [CL] in { def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst), - "shl{b}\t{%cl, $dst|$dst, %CL}", + "shl{b}\t{%cl, $dst|$dst, CL}", [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>; def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst), - "shl{w}\t{%cl, $dst|$dst, %CL}", + "shl{w}\t{%cl, $dst|$dst, CL}", [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize; def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst), - "shl{l}\t{%cl, $dst|$dst, %CL}", + "shl{l}\t{%cl, $dst|$dst, CL}", [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>; } def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src), @@ -1797,13 +1797,13 @@ let Uses = [CL] in { def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src), - "shr{b}\t{%cl, $dst|$dst, %CL}", + "shr{b}\t{%cl, $dst|$dst, CL}", [(set GR8:$dst, (srl GR8:$src, CL))]>; def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src), - "shr{w}\t{%cl, $dst|$dst, %CL}", + "shr{w}\t{%cl, $dst|$dst, CL}", [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize; def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src), - "shr{l}\t{%cl, $dst|$dst, %CL}", + "shr{l}\t{%cl, $dst|$dst, CL}", [(set GR32:$dst, (srl GR32:$src, CL))]>; } @@ -1831,14 +1831,14 @@ let isTwoAddress = 0 in { let Uses = [CL] in { def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst), - "shr{b}\t{%cl, $dst|$dst, %CL}", + "shr{b}\t{%cl, $dst|$dst, CL}", [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>; def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst), - "shr{w}\t{%cl, $dst|$dst, %CL}", + "shr{w}\t{%cl, $dst|$dst, CL}", [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize; def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst), - "shr{l}\t{%cl, $dst|$dst, %CL}", + "shr{l}\t{%cl, $dst|$dst, CL}", [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>; } def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src), @@ -1866,13 +1866,13 @@ let Uses = [CL] in { def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src), - "sar{b}\t{%cl, $dst|$dst, %CL}", + "sar{b}\t{%cl, $dst|$dst, CL}", [(set GR8:$dst, (sra GR8:$src, CL))]>; def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src), - "sar{w}\t{%cl, $dst|$dst, %CL}", + "sar{w}\t{%cl, $dst|$dst, CL}", [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize; def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src), - "sar{l}\t{%cl, $dst|$dst, %CL}", + "sar{l}\t{%cl, $dst|$dst, CL}", [(set GR32:$dst, (sra GR32:$src, CL))]>; } @@ -1901,13 +1901,13 @@ let isTwoAddress = 0 in { let Uses = [CL] in { def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst), - "sar{b}\t{%cl, $dst|$dst, %CL}", + "sar{b}\t{%cl, $dst|$dst, CL}", [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>; def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst), - "sar{w}\t{%cl, $dst|$dst, %CL}", + "sar{w}\t{%cl, $dst|$dst, CL}", [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize; def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst), - "sar{l}\t{%cl, $dst|$dst, %CL}", + "sar{l}\t{%cl, $dst|$dst, CL}", [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>; } def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src), @@ -1938,13 +1938,13 @@ // FIXME: provide shorter instructions when imm8 == 1 let Uses = [CL] in { def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), - "rol{b}\t{%cl, $dst|$dst, %CL}", + "rol{b}\t{%cl, $dst|$dst, CL}", [(set GR8:$dst, (rotl GR8:$src, CL))]>; def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src), - "rol{w}\t{%cl, $dst|$dst, %CL}", + "rol{w}\t{%cl, $dst|$dst, CL}", [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize; def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src), - "rol{l}\t{%cl, $dst|$dst, %CL}", + "rol{l}\t{%cl, $dst|$dst, CL}", [(set GR32:$dst, (rotl GR32:$src, CL))]>; } @@ -1972,13 +1972,13 @@ let isTwoAddress = 0 in { let Uses = [CL] in { def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst), - "rol{b}\t{%cl, $dst|$dst, %CL}", + "rol{b}\t{%cl, $dst|$dst, CL}", [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>; def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst), - "rol{w}\t{%cl, $dst|$dst, %CL}", + "rol{w}\t{%cl, $dst|$dst, CL}", [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize; def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst), - "rol{l}\t{%cl, $dst|$dst, %CL}", + "rol{l}\t{%cl, $dst|$dst, CL}", [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>; } def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src), @@ -2007,13 +2007,13 @@ let Uses = [CL] in { def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), - "ror{b}\t{%cl, $dst|$dst, %CL}", + "ror{b}\t{%cl, $dst|$dst, CL}", [(set GR8:$dst, (rotr GR8:$src, CL))]>; def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src), - "ror{w}\t{%cl, $dst|$dst, %CL}", + "ror{w}\t{%cl, $dst|$dst, CL}", [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize; def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src), - "ror{l}\t{%cl, $dst|$dst, %CL}", + "ror{l}\t{%cl, $dst|$dst, CL}", [(set GR32:$dst, (rotr GR32:$src, CL))]>; } @@ -2041,13 +2041,13 @@ let isTwoAddress = 0 in { let Uses = [CL] in { def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst), - "ror{b}\t{%cl, $dst|$dst, %CL}", + "ror{b}\t{%cl, $dst|$dst, CL}", [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>; def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst), - "ror{w}\t{%cl, $dst|$dst, %CL}", + "ror{w}\t{%cl, $dst|$dst, CL}", [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize; def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst), - "ror{l}\t{%cl, $dst|$dst, %CL}", + "ror{l}\t{%cl, $dst|$dst, CL}", [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>; } def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src), @@ -2079,17 +2079,17 @@ // Double shift instructions (generalizations of rotate) let Uses = [CL] in { def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2), - "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}", + "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}", [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB; def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2), - "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}", + "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}", [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB; def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), - "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}", + "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}", [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>, TB, OpSize; def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), - "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}", + "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}", [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>, TB, OpSize; } @@ -2124,11 +2124,11 @@ let isTwoAddress = 0 in { let Uses = [CL] in { def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), - "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}", + "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}", [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL), addr:$dst)]>, TB; def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), - "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}", + "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}", [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL), addr:$dst)]>, TB; } @@ -2147,11 +2147,11 @@ let Uses = [CL] in { def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), - "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}", + "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}", [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL), addr:$dst)]>, TB, OpSize; def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), - "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}", + "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}", [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL), addr:$dst)]>, TB, OpSize; } Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=73753&r1=73752&r2=73753&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Thu Jun 18 23:48:38 2009 @@ -303,8 +303,11 @@ GlobalPrefix = "_"; CommentString = ";"; + InlineAsmStart = "; InlineAsm Start"; + InlineAsmEnd = "; InlineAsm End"; + PrivateGlobalPrefix = "$"; - AlignDirective = "\talign\t"; + AlignDirective = "\tALIGN\t"; ZeroDirective = "\tdb\t"; ZeroDirectiveSuffix = " dup(0)"; AsciiDirective = "\tdb\t"; @@ -316,13 +319,15 @@ HasDotTypeDotSizeDirective = false; HasSingleParameterDotFile = false; + AlignmentIsInBytes = true; + TextSection = getUnnamedSection("_text", SectionFlags::Code); DataSection = getUnnamedSection("_data", SectionFlags::Writeable); JumpTableDataSection = NULL; SwitchToSectionDirective = ""; - TextSectionStartSuffix = "\tsegment 'CODE'"; - DataSectionStartSuffix = "\tsegment 'DATA'"; + TextSectionStartSuffix = "\tSEGMENT PARA 'CODE'"; + DataSectionStartSuffix = "\tSEGMENT PARA 'DATA'"; SectionEndDirectiveSuffix = "\tends\n"; } From nicholas at mxc.ca Thu Jun 18 23:56:29 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 19 Jun 2009 04:56:29 -0000 Subject: [llvm-commits] [llvm] r73755 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/branch-no-const.ll Message-ID: <200906190456.n5J4uTS5008791@zion.cs.uiuc.edu> Author: nicholas Date: Thu Jun 18 23:56:29 2009 New Revision: 73755 URL: http://llvm.org/viewvc/llvm-project?rev=73755&view=rev Log: Teach jump threading to look at comparisons between phi nodes and non-constants. Added: llvm/trunk/test/Transforms/JumpThreading/branch-no-const.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=73755&r1=73754&r2=73755&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Thu Jun 18 23:56:29 2009 @@ -76,7 +76,7 @@ bool ProcessBlock(BasicBlock *BB); bool ThreadEdge(BasicBlock *BB, BasicBlock *PredBB, BasicBlock *SuccBB, unsigned JumpThreadCost); - BasicBlock *FactorCommonPHIPreds(PHINode *PN, Constant *CstVal); + BasicBlock *FactorCommonPHIPreds(PHINode *PN, Value *Val); bool ProcessBranchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); bool ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, BasicBlock *DestBB); @@ -163,10 +163,10 @@ /// This is important for things like "phi i1 [true, true, false, true, x]" /// where we only need to clone the block for the true blocks once. /// -BasicBlock *JumpThreading::FactorCommonPHIPreds(PHINode *PN, Constant *CstVal) { +BasicBlock *JumpThreading::FactorCommonPHIPreds(PHINode *PN, Value *Val) { SmallVector CommonPreds; for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) - if (PN->getIncomingValue(i) == CstVal) + if (PN->getIncomingValue(i) == Val) CommonPreds.push_back(PN->getIncomingBlock(i)); if (CommonPreds.size() == 1) @@ -346,13 +346,19 @@ CondInst->getOpcode() == Instruction::And)) return true; - // If we have "br (phi != 42)" and the phi node has any constant values as - // operands, we can thread through this block. - if (CmpInst *CondCmp = dyn_cast(CondInst)) - if (isa(CondCmp->getOperand(0)) && - isa(CondCmp->getOperand(1)) && - ProcessBranchOnCompare(CondCmp, BB)) - return true; + if (CmpInst *CondCmp = dyn_cast(CondInst)) { + if (isa(CondCmp->getOperand(0))) { + // If we have "br (phi != 42)" and the phi node has any constant values + // as operands, we can thread through this block. + // + // If we have "br (cmp phi, x)" and the phi node contains x such that the + // comparison uniquely identifies the branch target, we can thread + // through this block. + + if (ProcessBranchOnCompare(CondCmp, BB)) + return true; + } + } // Check for some cases that are worth simplifying. Right now we want to look // for loads that are used by a switch or by the condition for the branch. If @@ -770,12 +776,30 @@ return ThreadEdge(BB, PredBB, SuccBB, JumpThreadCost); } +/// GetResultOfComparison - Given an icmp/fcmp predicate and the left and right +/// hand sides of the compare instruction, try to determine the result. If the +/// result can not be determined, a null pointer is returned. +static Constant *GetResultOfComparison(CmpInst::Predicate pred, + Value *LHS, Value *RHS) { + if (Constant *CLHS = dyn_cast(LHS)) + if (Constant *CRHS = dyn_cast(RHS)) + return ConstantExpr::getCompare(pred, CLHS, CRHS); + + if (LHS == RHS) + if (isa(LHS->getType()) || isa(LHS->getType())) + return ICmpInst::isTrueWhenEqual(pred) ? + ConstantInt::getTrue() : ConstantInt::getFalse(); + + return 0; +} + /// ProcessBranchOnCompare - We found a branch on a comparison between a phi -/// node and a constant. If the PHI node contains any constants as inputs, we -/// can fold the compare for that edge and thread through it. +/// node and a value. If we can identify when the comparison is true between +/// the phi inputs and the value, we can fold the compare for that edge and +/// thread through it. bool JumpThreading::ProcessBranchOnCompare(CmpInst *Cmp, BasicBlock *BB) { PHINode *PN = cast(Cmp->getOperand(0)); - Constant *RHS = cast(Cmp->getOperand(1)); + Value *RHS = Cmp->getOperand(1); // If the phi isn't in the current block, an incoming edge to this block // doesn't control the destination. @@ -784,18 +808,17 @@ // We can do this simplification if any comparisons fold to true or false. // See if any do. - Constant *PredCst = 0; + Value *PredVal = 0; bool TrueDirection = false; for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - PredCst = dyn_cast(PN->getIncomingValue(i)); - if (PredCst == 0) continue; + PredVal = PN->getIncomingValue(i); + + Constant *Res = GetResultOfComparison(Cmp->getPredicate(), PredVal, RHS); + if (!Res) { + PredVal = 0; + continue; + } - Constant *Res; - if (ICmpInst *ICI = dyn_cast(Cmp)) - Res = ConstantExpr::getICmp(ICI->getPredicate(), PredCst, RHS); - else - Res = ConstantExpr::getFCmp(cast(Cmp)->getPredicate(), - PredCst, RHS); // If this folded to a constant expr, we can't do anything. if (ConstantInt *ResC = dyn_cast(Res)) { TrueDirection = ResC->getZExtValue(); @@ -808,11 +831,11 @@ } // Otherwise, we can't fold this input. - PredCst = 0; + PredVal = 0; } // If no match, bail out. - if (PredCst == 0) + if (PredVal == 0) return false; // See if the cost of duplicating this block is low enough. @@ -825,7 +848,7 @@ // If so, we can actually do this threading. Merge any common predecessors // that will act the same. - BasicBlock *PredBB = FactorCommonPHIPreds(PN, PredCst); + BasicBlock *PredBB = FactorCommonPHIPreds(PN, PredVal); // Next, get our successor. BasicBlock *SuccBB = BB->getTerminator()->getSuccessor(!TrueDirection); Added: llvm/trunk/test/Transforms/JumpThreading/branch-no-const.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/branch-no-const.ll?rev=73755&view=auto ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/branch-no-const.ll (added) +++ llvm/trunk/test/Transforms/JumpThreading/branch-no-const.ll Thu Jun 18 23:56:29 2009 @@ -0,0 +1,21 @@ +; RUN: llvm-as < %s | opt -jump-threading | llvm-dis | not grep phi + +declare i8 @mcguffin() + +define i32 @test(i1 %foo, i8 %b) { +entry: + %a = call i8 @mcguffin() + br i1 %foo, label %bb1, label %bb2 +bb1: + br label %jt +bb2: + br label %jt +jt: + %x = phi i8 [%a, %bb1], [%b, %bb2] + %A = icmp eq i8 %x, %a + br i1 %A, label %rt, label %rf +rt: + ret i32 7 +rf: + ret i32 8 +} From eli.friedman at gmail.com Fri Jun 19 01:01:55 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 19 Jun 2009 06:01:55 -0000 Subject: [llvm-commits] [llvm] r73757 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Message-ID: <200906190601.n5J61ten011204@zion.cs.uiuc.edu> Author: efriedma Date: Fri Jun 19 01:01:55 2009 New Revision: 73757 URL: http://llvm.org/viewvc/llvm-project?rev=73757&view=rev Log: Minor cleanup; fixes review comments for a previous patch. Sorry for taking so long to get to this! Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp?rev=73757&r1=73756&r2=73757&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp Fri Jun 19 01:01:55 2009 @@ -95,14 +95,13 @@ if (InVT.isVector() && OutVT.isInteger()) { // Handle cases like i64 = BIT_CONVERT v1i64 on x86, where the operand // is legal but the result is not. - MVT NVT = MVT::getVectorVT(TLI.getTypeToTransformTo(OutVT), 2); + MVT NVT = MVT::getVectorVT(NOutVT, 2); if (isTypeLegal(NVT)) { SDValue CastInOp = DAG.getNode(ISD::BIT_CONVERT, dl, NVT, InOp); - MVT EltNVT = NVT.getVectorElementType(); - Lo = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltNVT, CastInOp, + Lo = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, NOutVT, CastInOp, DAG.getIntPtrConstant(0)); - Hi = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltNVT, CastInOp, + Hi = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, NOutVT, CastInOp, DAG.getIntPtrConstant(1)); if (TLI.isBigEndian()) From evan.cheng at apple.com Fri Jun 19 01:52:26 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 18 Jun 2009 23:52:26 -0700 Subject: [llvm-commits] [llvm] r73746 - in /llvm/trunk: lib/Target/ARM/ARMInstrThumb.td test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll In-Reply-To: <200906190143.n5J1h99X032493@zion.cs.uiuc.edu> References: <200906190143.n5J1h99X032493@zion.cs.uiuc.edu> Message-ID: <89DC2B1E-9128-466F-9C48-4CFE5FF137B2@apple.com> On Jun 18, 2009, at 6:43 PM, Eli Friedman wrote: > Author: efriedma > Date: Thu Jun 18 20:43:08 2009 > New Revision: 73746 > > URL: http://llvm.org/viewvc/llvm-project?rev=73746&view=rev > Log: > Mark a few Thumb instructions commutable; just happened to spot this > while experimenting. I'm reasonably sure this is correct, but please > tell me if these instructions have some strange property which makes > this > change unsafe. It's right. Looks like we are missing the isCommutable markers on the ARM side as well. Evan > > > > Added: > llvm/trunk/test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll > Modified: > llvm/trunk/lib/Target/ARM/ARMInstrThumb.td > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=73746&r1=73745&r2=73746&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Thu Jun 18 20:43:08 > 2009 > @@ -277,6 +277,7 @@ > // > > // Add with carry > +let isCommutable = 1 in > def tADC : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), > "adc $dst, $rhs", > [(set tGPR:$dst, (adde tGPR:$lhs, tGPR:$rhs))]>; > @@ -311,6 +312,7 @@ > def tADDspi : TIt<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs), > "add $dst, $rhs * 4", []>; > > +let isCommutable = 1 in > def tAND : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), > "and $dst, $rhs", > [(set tGPR:$dst, (and tGPR:$lhs, tGPR:$rhs))]>; > @@ -358,6 +360,7 @@ > > // TODO: A7-37: CMP(3) - cmp hi regs > > +let isCommutable = 1 in > def tEOR : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), > "eor $dst, $rhs", > [(set tGPR:$dst, (xor tGPR:$lhs, tGPR:$rhs))]>; > @@ -399,6 +402,7 @@ > "cpy $dst, $src\t@ hir2hir", []>; > } // neverHasSideEffects > > +let isCommutable = 1 in > def tMUL : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), > "mul $dst, $rhs", > [(set tGPR:$dst, (mul tGPR:$lhs, tGPR:$rhs))]>; > @@ -411,6 +415,7 @@ > "neg $dst, $src", > [(set tGPR:$dst, (ineg tGPR:$src))]>; > > +let isCommutable = 1 in > def tORR : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), > "orr $dst, $rhs", > [(set tGPR:$dst, (or tGPR:$lhs, tGPR:$rhs))]>; > > Added: llvm/trunk/test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll?rev=73746&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll (added) > +++ llvm/trunk/test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll Thu > Jun 18 20:43:08 2009 > @@ -0,0 +1,8 @@ > +; RUN: llvm-as < %s | llc -march=thumb | grep r0 | count 1 > + > +define i32 @a(i32 %x, i32 %y) nounwind readnone { > +entry: > + %mul = mul i32 %y, %x ; [#uses=1] > + ret i32 %mul > +} > + > > > _______________________________________________ > 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 Fri Jun 19 01:56:26 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 19 Jun 2009 06:56:26 -0000 Subject: [llvm-commits] [llvm] r73759 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <200906190656.n5J6uRcN012940@zion.cs.uiuc.edu> Author: evancheng Date: Fri Jun 19 01:56:26 2009 New Revision: 73759 URL: http://llvm.org/viewvc/llvm-project?rev=73759&view=rev Log: Should be using Bcc (average) latency to determine if-conversion threshold, not BL. 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=73759&r1=73758&r2=73759&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Jun 19 01:56:26 2009 @@ -296,7 +296,7 @@ // Use branch latency information to determine if-conversion limits. const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); const InstrItineraryData &InstrItins = Subtarget->getInstrItineraryData(); - unsigned Latency = InstrItins.getLatency(TII->get(ARM::BL).getSchedClass()); + unsigned Latency= InstrItins.getLatency(TII->get(ARM::Bcc).getSchedClass()); if (Latency > 1) { setIfCvtBlockSizeLimit(Latency-1); if (Latency > 2) From eli.friedman at gmail.com Fri Jun 19 02:00:55 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 19 Jun 2009 07:00:55 -0000 Subject: [llvm-commits] [llvm] r73760 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/2009-06-18-movlp-shuffle-register.ll Message-ID: <200906190700.n5J70tnb013070@zion.cs.uiuc.edu> Author: efriedma Date: Fri Jun 19 02:00:55 2009 New Revision: 73760 URL: http://llvm.org/viewvc/llvm-project?rev=73760&view=rev Log: Fix for PR2484: add an SSE1 pattern for a shuffle we normally prefer to handle with an SSE2 instruction. Added: llvm/trunk/test/CodeGen/X86/2009-06-18-movlp-shuffle-register.ll 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=73760&r1=73759&r2=73760&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri Jun 19 02:00:55 2009 @@ -3027,6 +3027,12 @@ (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>; } +// vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but +// fall back to this for SSE1) +def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))), + (SHUFPSrri VR128:$src2, VR128:$src1, + (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>; + // Set lowest element and zero upper elements. let AddedComplexity = 15 in def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)), Added: llvm/trunk/test/CodeGen/X86/2009-06-18-movlp-shuffle-register.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-06-18-movlp-shuffle-register.ll?rev=73760&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-06-18-movlp-shuffle-register.ll (added) +++ llvm/trunk/test/CodeGen/X86/2009-06-18-movlp-shuffle-register.ll Fri Jun 19 02:00:55 2009 @@ -0,0 +1,9 @@ +; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse,-sse2 +; PR2484 + +define <4 x float> @f4523(<4 x float> %a,<4 x float> %b) nounwind { +entry: +%shuffle = shufflevector <4 x float> %a, <4 x float> %b, <4 x i32> +ret <4 x float> %shuffle +} From evan.cheng at apple.com Fri Jun 19 02:06:15 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 19 Jun 2009 07:06:15 -0000 Subject: [llvm-commits] [llvm] r73761 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <200906190706.n5J76IU4013254@zion.cs.uiuc.edu> Author: evancheng Date: Fri Jun 19 02:06:07 2009 New Revision: 73761 URL: http://llvm.org/viewvc/llvm-project?rev=73761&view=rev Log: Add comments. 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=73761&r1=73760&r2=73761&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Jun 19 02:06:07 2009 @@ -294,6 +294,10 @@ if (!Subtarget->isThumb()) { // Use branch latency information to determine if-conversion limits. + // FIXME: If-converter should use instruction latency of the branch being + // eliminated to compute the threshold. For ARMv6, the branch "latency" + // varies depending on whether it's dynamically or statically predicted + // and on whether the destination is in the prefetch buffer. const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); const InstrItineraryData &InstrItins = Subtarget->getInstrItineraryData(); unsigned Latency= InstrItins.getLatency(TII->get(ARM::Bcc).getSchedClass()); From eli.friedman at gmail.com Fri Jun 19 02:13:51 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 19 Jun 2009 00:13:51 -0700 Subject: [llvm-commits] [llvm] r73746 - in /llvm/trunk: lib/Target/ARM/ARMInstrThumb.td test/CodeGen/ARM/2009-06-18-ThumbCommuteMul.ll In-Reply-To: <89DC2B1E-9128-466F-9C48-4CFE5FF137B2@apple.com> References: <200906190143.n5J1h99X032493@zion.cs.uiuc.edu> <89DC2B1E-9128-466F-9C48-4CFE5FF137B2@apple.com> Message-ID: On Thu, Jun 18, 2009 at 11:52 PM, Evan Cheng wrote: > > On Jun 18, 2009, at 6:43 PM, Eli Friedman wrote: > >> Author: efriedma >> Date: Thu Jun 18 20:43:08 2009 >> New Revision: 73746 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=73746&view=rev >> Log: >> Mark a few Thumb instructions commutable; just happened to spot this >> while experimenting. ?I'm reasonably sure this is correct, but please >> tell me if these instructions have some strange property which makes >> this >> change unsafe. > > It's right. Looks like we are missing the isCommutable markers on the > ARM side as well. Are there any non-Thumb instructions where it's relevant? -Eli From baldrick at free.fr Fri Jun 19 03:42:45 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Jun 2009 10:42:45 +0200 Subject: [llvm-commits] [llvm] r73701 - /llvm/trunk/lib/VMCore/Pass.cpp In-Reply-To: <200906181608.n5IG8a3R000716@zion.cs.uiuc.edu> References: <200906181608.n5IG8a3R000716@zion.cs.uiuc.edu> Message-ID: <4A3B4F85.1070803@free.fr> Hi Owen, does sys::MemoryFence compile to nothing if !llvm_is_multithreaded? On SMP machines memory fences can be expensive, so using it when not actually needed could be costly. So best to avoid it if LLVM is not running multithreaded. Since the new memory barrier you added only has to happen before returning PassRegistrarObj, I guess you could do something like this: PassRegistrar* tmp = PassRegistrarObj; if (llvm_is_multithreaded()) { sys::MemoryFence(); if (!tmp) { llvm_acquire_global_lock(); tmp = PassRegistrarObj; if (!tmp) { tmp = new PassRegistrar(); sys::MemoryFence(); PassRegistrarObj = tmp; } llvm_release_global_lock(); } } else if (!tmp) { PassRegistrarObj = tmp = new PassRegistrar(); } return tmp; Ciao, Duncan. From baldrick at free.fr Fri Jun 19 03:49:01 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Jun 2009 10:49:01 +0200 Subject: [llvm-commits] [llvm] r73712 - /llvm/trunk/lib/VMCore/Type.cpp In-Reply-To: <200906181836.n5IIaoGW009995@zion.cs.uiuc.edu> References: <200906181836.n5IIaoGW009995@zion.cs.uiuc.edu> Message-ID: <4A3B50FD.8060609@free.fr> Hi Owen, > +// NOTE: The false template parameter means this will no-op when we're not in > +// multithreaded mode. > +static ManagedStatic > AbstractTypeUsersLock; the template parameter seems to be "true" rather than "false", in disagreement with the comment. Ciao, Duncan. From baldrick at free.fr Fri Jun 19 03:58:52 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Jun 2009 10:58:52 +0200 Subject: [llvm-commits] [llvm] r73721 - /llvm/trunk/lib/VMCore/TypeSymbolTable.cpp In-Reply-To: <200906182044.n5IKiV2p015393@zion.cs.uiuc.edu> References: <200906182044.n5IKiV2p015393@zion.cs.uiuc.edu> Message-ID: <4A3B534C.8080504@free.fr> Hi Owen, > Simplify with SmartRWMutex. when compiling without multithreading but with assertions enabled you might want to have these smart mutexes still do same sanity checking to try to catch cases when you would get a deadlock in the multithreaded version. For example, for a simple mutex you can have a flag "acquired", set when acquiring and cleared when released, and assert that the flag is not already set when acquiring, and assert that the flag is set when releasing. For other kinds of mutexes you can use a counter etc. Anyway, the point is that many many more people will probably run the singlethreaded LLVM, so this kind of trick helps you get limited multithreading testing from such people nonetheless. Ciao, Duncan. From baldrick at free.fr Fri Jun 19 04:39:25 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Jun 2009 11:39:25 +0200 Subject: [llvm-commits] Cyclic dependencies between LLVM libraries with debug builds In-Reply-To: References: <4A3A14AA.4020105@free.fr> Message-ID: <4A3B5CCD.8040705@free.fr> Hi Chris, >> If I configure without any options (equivalent to --disable-optimized >> --enable-assertions) on x64-64 linux then the build fails with: >> >> llvm[1]: Checking for cyclic dependencies between LLVM libraries. >> find-cycles.pl: Circular dependency between *.a files: >> find-cycles.pl: libLLVMSparcAsmPrinter.a libLLVMSparcCodeGen.a >> find-cycles.pl: Circular dependency between *.a files: >> find-cycles.pl: libLLVMCellSPUAsmPrinter.a libLLVMCellSPUCodeGen.a >> find-cycles.pl: Circular dependency between *.a files: >> find-cycles.pl: libLLVMAlphaAsmPrinter.a libLLVMAlphaCodeGen.a >> find-cycles.pl: Circular dependency between *.a files: >> find-cycles.pl: libLLVMIA64AsmPrinter.a libLLVMIA64CodeGen.a >> >> Any ideas? > > I'm not seeing that. Can you go into tools/llvm-config and run an > appropriately path-adjusted version of this: > > /usr/bin/perl /Users/sabre/llvm/utils/GenLibDeps.pl -flat -why /Users/ > sabre/llvm/Debug/lib "/usr/bin/nm -p" > out.txt > > and send me out.txt? here you go (attached). For example, libLLVMSparcAsmPrinter.a depends on libLLVMSparcCodeGen.a because of these symbols: _ZN4llvm2SP14FPRegsRegClassE _ZN4llvm2SP15DFPRegsRegClassE _ZN4llvm2SP15IntRegsRegClassE While libLLVMSparcCodeGen.a depends on libLLVMSparcAsmPrinter.a because of this symbol: _ZN4llvm26createSparcCodePrinterPassERNS_11raw_ostreamERNS_13TargetMachineENS_10CodeGenOpt5LevelEb Ciao, Duncan. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: out.txt Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090619/f722fe91/attachment.txt From baldrick at free.fr Fri Jun 19 07:40:42 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Jun 2009 12:40:42 -0000 Subject: [llvm-commits] [llvm] r73765 - /llvm/trunk/Makefile.rules Message-ID: <200906191240.n5JCeiqT004885@zion.cs.uiuc.edu> Author: baldrick Date: Fri Jun 19 07:40:30 2009 New Revision: 73765 URL: http://llvm.org/viewvc/llvm-project?rev=73765&view=rev Log: Since -Wno-long-long is ignored without -pedantic, place it with -pedantic. Remove -Wunused since it is implied by -Wall. Group -Wno-unused-parameter with -Wall -W since it is the combination of these two that turns on -Wunused-parameter. Modified: llvm/trunk/Makefile.rules Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=73765&r1=73764&r2=73765&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Fri Jun 19 07:40:30 2009 @@ -519,10 +519,10 @@ #---------------------------------------------------------- ifndef NO_PEDANTIC -CompileCommonOpts += -pedantic +CompileCommonOpts += -pedantic -Wno-long-long endif -CompileCommonOpts += -Wall -W -Wwrite-strings -Wno-long-long \ - -Wunused -Wno-unused-parameter $(EXTRA_OPTIONS) +CompileCommonOpts += -Wall -W -Wno-unused-parameter -Wwrite-strings \ + $(EXTRA_OPTIONS) ifeq ($(OS),HP-UX) CompileCommonOpts := -D_REENTRANT -D_HPUX_SOURCE From baldrick at free.fr Fri Jun 19 09:40:08 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Jun 2009 14:40:08 -0000 Subject: [llvm-commits] [llvm] r73766 - in /llvm/trunk: include/llvm/ADT/Triple.h lib/Support/Triple.cpp Message-ID: <200906191440.n5JEeAqS009730@zion.cs.uiuc.edu> Author: baldrick Date: Fri Jun 19 09:40:01 2009 New Revision: 73766 URL: http://llvm.org/viewvc/llvm-project?rev=73766&view=rev Log: Add support for AuroraUX. Patch by evocallaghan. Modified: llvm/trunk/include/llvm/ADT/Triple.h llvm/trunk/lib/Support/Triple.cpp Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=73766&r1=73765&r2=73766&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Fri Jun 19 09:40:01 2009 @@ -49,6 +49,7 @@ enum OSType { UnknownOS, + AuroraUX, Darwin, DragonFly, FreeBSD, Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=73766&r1=73765&r2=73766&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Fri Jun 19 09:40:01 2009 @@ -43,6 +43,7 @@ switch (Kind) { case UnknownOS: return "unknown"; + case AuroraUX: return "auroraux"; case Darwin: return "darwin"; case DragonFly: return "dragonfly"; case FreeBSD: return "freebsd"; @@ -79,7 +80,9 @@ Vendor = UnknownVendor; std::string OSName = getOSName(); - if (memcmp(&OSName[0], "darwin", 6) == 0) + if (memcmp(&OSName[0], "auroraux", 8) == 0) + OS = AuroraUX; + else if (memcmp(&OSName[0], "darwin", 6) == 0) OS = Darwin; else if (memcmp(&OSName[0], "dragonfly", 9) == 0) OS = DragonFly; From sabre at nondot.org Fri Jun 19 10:48:38 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Jun 2009 15:48:38 -0000 Subject: [llvm-commits] [llvm] r73767 - in /llvm/trunk/lib/Target/Sparc: AsmPrinter/SparcAsmPrinter.cpp SparcTargetMachine.cpp SparcTargetMachine.h Message-ID: <200906191548.n5JFmjLa012182@zion.cs.uiuc.edu> Author: lattner Date: Fri Jun 19 10:48:10 2009 New Revision: 73767 URL: http://llvm.org/viewvc/llvm-project?rev=73767&view=rev Log: fix the sparc codegen to not depend on the sparc asmprinter. Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp llvm/trunk/lib/Target/Sparc/SparcTargetMachine.h Modified: llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp?rev=73767&r1=73766&r2=73767&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp Fri Jun 19 10:48:10 2009 @@ -15,6 +15,7 @@ #define DEBUG_TYPE "asm-printer" #include "Sparc.h" #include "SparcInstrInfo.h" +#include "SparcTargetMachine.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" @@ -24,8 +25,6 @@ #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetAsmInfo.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetMachine.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/Statistic.h" @@ -88,6 +87,7 @@ return new SparcAsmPrinter(o, tm, tm.getTargetAsmInfo(), OptLevel, verbose); } + /// runOnMachineFunction - This uses the printInstruction() /// method to print assembly for each instruction. /// @@ -354,6 +354,14 @@ return false; } +namespace { + static struct Register { + Register() { + SparcTargetMachine::registerAsmPrinter(createSparcCodePrinterPass); + } + } Registrator; +} + // Force static initialization when called from // llvm/InitializeAllAsmPrinters.h namespace llvm { Modified: llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp?rev=73767&r1=73766&r2=73767&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp Fri Jun 19 10:48:10 2009 @@ -18,17 +18,13 @@ #include "llvm/Target/TargetMachineRegistry.h" using namespace llvm; -/// SparcTargetMachineModule - Note that this is used on hosts that -/// cannot link in a library unless there are references into the -/// library. In particular, it seems that it is not possible to get -/// things to work on Win32 without this. Though it is unused, do not -/// remove it. -extern "C" int SparcTargetMachineModule; -int SparcTargetMachineModule = 0; - // Register the target. static RegisterTarget X("sparc", "SPARC"); +// No assembler printer by default +SparcTargetMachine::AsmPrinterCtorFn SparcTargetMachine::AsmPrinterCtor = 0; + + // Force static initialization when called from llvm/InitializeAllTargets.h namespace llvm { void InitializeSparcTarget() { } @@ -94,6 +90,8 @@ bool Verbose, raw_ostream &Out) { // Output assembly language. - PM.add(createSparcCodePrinterPass(Out, *this, OptLevel, Verbose)); + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(Out, *this, OptLevel, Verbose)); return false; } Modified: llvm/trunk/lib/Target/Sparc/SparcTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetMachine.h?rev=73767&r1=73766&r2=73767&view=diff ============================================================================== --- llvm/trunk/lib/Target/Sparc/SparcTargetMachine.h (original) +++ llvm/trunk/lib/Target/Sparc/SparcTargetMachine.h Fri Jun 19 10:48:10 2009 @@ -35,6 +35,14 @@ protected: virtual const TargetAsmInfo *createTargetAsmInfo() const; + // To avoid having target depend on the asmprinter stuff libraries, asmprinter + // set this functions to ctor pointer at startup time if they are linked in. + typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o, + TargetMachine &tm, + CodeGenOpt::Level OptLevel, + bool verbose); + static AsmPrinterCtorFn AsmPrinterCtor; + public: SparcTargetMachine(const Module &M, const std::string &FS); @@ -56,6 +64,10 @@ virtual bool addAssemblyEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool Verbose, raw_ostream &Out); + + static void registerAsmPrinter(AsmPrinterCtorFn F) { + AsmPrinterCtor = F; + } }; } // end namespace llvm From clattner at apple.com Fri Jun 19 10:48:58 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 19 Jun 2009 08:48:58 -0700 Subject: [llvm-commits] Cyclic dependencies between LLVM libraries with debug builds In-Reply-To: <4A3B5CCD.8040705@free.fr> References: <4A3A14AA.4020105@free.fr> <4A3B5CCD.8040705@free.fr> Message-ID: <4A76F22F-EC35-46AE-AC3D-8E12FC5F9A49@apple.com> On Jun 19, 2009, at 2:39 AM, Duncan Sands wrote: >> I'm not seeing that. Can you go into tools/llvm-config and run an >> appropriately path-adjusted version of this: >> /usr/bin/perl /Users/sabre/llvm/utils/GenLibDeps.pl -flat -why / >> Users/ sabre/llvm/Debug/lib "/usr/bin/nm -p" > out.txt >> and send me out.txt? > > here you go (attached). For example, libLLVMSparcAsmPrinter.a depends > on libLLVMSparcCodeGen.a because of these symbols: > _ZN4llvm2SP14FPRegsRegClassE > _ZN4llvm2SP15DFPRegsRegClassE > _ZN4llvm2SP15IntRegsRegClassE > While libLLVMSparcCodeGen.a depends on libLLVMSparcAsmPrinter.a > because > of this symbol: > _ZN4llvm26createSparcCodePrinterPassERNS_11raw_ostreamERNS_13TargetMachineENS_10CodeGenOpt5LevelEb Well that's definitely a problem. r73767 should fix this, I wonder why I don't see this. :( -Chris From nicolas.geoffray at lip6.fr Fri Jun 19 11:16:51 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 19 Jun 2009 18:16:51 +0200 Subject: [llvm-commits] [llvm] r73711 - /llvm/trunk/include/llvm/System/Mutex.h In-Reply-To: <200906181829.n5IIT4Bx009771@zion.cs.uiuc.edu> References: <200906181829.n5IIT4Bx009771@zion.cs.uiuc.edu> Message-ID: <4A3BB9F3.4030606@lip6.fr> Hi Owen, This patch makes multithreaded applications do lots of sigsegvs, even if I call start_multithread at the beginning of my main function. I haven't looked at why yet, only tracked the error down to this revision. Could you double-check your code? Thanks! Nicolas Owen Anderson wrote: > Author: resistor > Date: Thu Jun 18 13:29:03 2009 > New Revision: 73711 > > URL: http://llvm.org/viewvc/llvm-project?rev=73711&view=rev > Log: > Simplify the SmartMutex implementation a bit. > > Modified: > llvm/trunk/include/llvm/System/Mutex.h > > Modified: llvm/trunk/include/llvm/System/Mutex.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Mutex.h?rev=73711&r1=73710&r2=73711&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/System/Mutex.h (original) > +++ llvm/trunk/include/llvm/System/Mutex.h Thu Jun 18 13:29:03 2009 > @@ -86,31 +86,30 @@ > /// indicates whether this mutex should become a no-op when we're not > /// running in multithreaded mode. > template > - class SmartMutex { > - MutexImpl mtx; > + class SmartMutex : public MutexImpl { > public: > - explicit SmartMutex(bool recursive = true) : mtx(recursive) { } > + explicit SmartMutex(bool recursive = true) : MutexImpl(recursive) { } > > bool acquire() { > - if (!mt_only || (mt_only && llvm_is_multithreaded())) > - return mtx.acquire(); > + if (!mt_only && llvm_is_multithreaded()) > + return MutexImpl::acquire(); > return true; > } > > bool release() { > - if (!mt_only || (mt_only && llvm_is_multithreaded())) > - return mtx.release(); > + if (!mt_only || llvm_is_multithreaded()) > + return MutexImpl::release(); > return true; > } > > bool tryacquire() { > - if (!mt_only || (mt_only && llvm_is_multithreaded())) > - return mtx.tryacquire(); > + if (!mt_only || llvm_is_multithreaded()) > + return MutexImpl::tryacquire(); > return true; > } > > private: > - SmartMutex(const SmartMutex & original); > + SmartMutex(const SmartMutex & original); > void operator=(const SmartMutex &); > }; > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Fri Jun 19 11:28:03 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Jun 2009 16:28:03 -0000 Subject: [llvm-commits] [llvm] r73768 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/dup-cond.ll Message-ID: <200906191628.n5JGS5fL013520@zion.cs.uiuc.edu> Author: lattner Date: Fri Jun 19 11:27:56 2009 New Revision: 73768 URL: http://llvm.org/viewvc/llvm-project?rev=73768&view=rev Log: make jump threading handle lexically identical compare instructions as if they were multiple uses of the same instruction. This interacts well with the existing loadpre that j-t does to open up many new jump threads earlier. Added: llvm/trunk/test/Transforms/JumpThreading/dup-cond.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=73768&r1=73767&r2=73768&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Jun 19 11:27:56 2009 @@ -324,10 +324,6 @@ } } - // If there is only a single predecessor of this block, nothing to fold. - if (BB->getSinglePredecessor()) - return false; - // All the rest of our checks depend on the condition being an instruction. if (CondInst == 0) return false; @@ -358,6 +354,23 @@ if (ProcessBranchOnCompare(CondCmp, BB)) return true; } + + // If we have a comparison, loop over the predecessors to see if there is + // a condition with the same value. + pred_iterator PI = pred_begin(BB), E = pred_end(BB); + for (; PI != E; ++PI) + if (BranchInst *PBI = dyn_cast((*PI)->getTerminator())) + if (PBI->isConditional() && *PI != BB) { + if (CmpInst *CI = dyn_cast(PBI->getCondition())) { + if (CI->getOperand(0) == CondCmp->getOperand(0) && + CI->getOperand(1) == CondCmp->getOperand(1) && + CI->getPredicate() == CondCmp->getPredicate()) { + // TODO: Could handle things like (x != 4) --> (x == 17) + if (ProcessBranchOnDuplicateCond(*PI, BB)) + return true; + } + } + } } // Check for some cases that are worth simplifying. Right now we want to look Added: llvm/trunk/test/Transforms/JumpThreading/dup-cond.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/dup-cond.ll?rev=73768&view=auto ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/dup-cond.ll (added) +++ llvm/trunk/test/Transforms/JumpThreading/dup-cond.ll Fri Jun 19 11:27:56 2009 @@ -0,0 +1,30 @@ +; RUN: llvm-as < %s | opt -jump-threading -die | llvm-dis | grep icmp | count 1 + +declare void @f1() +declare void @f2() +declare void @f3() + +define i32 @test(i32 %A) { + %tmp455 = icmp eq i32 %A, 42 + br i1 %tmp455, label %BB1, label %BB2 + +BB2: + call void @f1() + br label %BB1 + + +BB1: + %tmp459 = icmp eq i32 %A, 42 + br i1 %tmp459, label %BB3, label %BB4 + +BB3: + call void @f2() + ret i32 3 + +BB4: + call void @f3() + ret i32 4 +} + + + From resistor at mac.com Fri Jun 19 11:56:08 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 09:56:08 -0700 Subject: [llvm-commits] [llvm] r73711 - /llvm/trunk/include/llvm/System/Mutex.h In-Reply-To: <4A3BB9F3.4030606@lip6.fr> References: <200906181829.n5IIT4Bx009771@zion.cs.uiuc.edu> <4A3BB9F3.4030606@lip6.fr> Message-ID: <36D0E94C-90E9-491B-BA34-6B27689B4B8B@mac.com> On Jun 19, 2009, at 9:16 AM, Nicolas Geoffray wrote: > Hi Owen, > > This patch makes multithreaded applications do lots of sigsegvs, > even if > I call start_multithread at the beginning of my main function. I > haven't > looked at why yet, only tracked the error down to this revision. Could > you double-check your code? Did you try after r73745? That fixed some weird errors due to ENABLE_THREADS not being defined in every cpp file. --Owen From criswell at uiuc.edu Fri Jun 19 12:03:53 2009 From: criswell at uiuc.edu (John Criswell) Date: Fri, 19 Jun 2009 17:03:53 -0000 Subject: [llvm-commits] [poolalloc] r73769 - in /poolalloc/trunk: runtime/FL2Allocator/PoolAllocator.cpp tools/Pa/pa.cpp Message-ID: <200906191703.n5JH3uN3014670@zion.cs.uiuc.edu> Author: criswell Date: Fri Jun 19 12:03:36 2009 New Revision: 73769 URL: http://llvm.org/viewvc/llvm-project?rev=73769&view=rev Log: Modified code to remove compilation warnings. No functionality changes (I hope). Modified: poolalloc/trunk/runtime/FL2Allocator/PoolAllocator.cpp poolalloc/trunk/tools/Pa/pa.cpp Modified: poolalloc/trunk/runtime/FL2Allocator/PoolAllocator.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/FL2Allocator/PoolAllocator.cpp?rev=73769&r1=73768&r2=73769&view=diff ============================================================================== --- poolalloc/trunk/runtime/FL2Allocator/PoolAllocator.cpp (original) +++ poolalloc/trunk/runtime/FL2Allocator/PoolAllocator.cpp Fri Jun 19 12:03:36 2009 @@ -372,13 +372,13 @@ Pool->ObjFreeList = 0; // This is our bump pointer. Pool->OtherFreeList = 0; // This is our end pointer. - unsigned PID; #ifdef ENABLE_POOL_IDS + unsigned PID; PID = addPoolNumber(Pool); -#endif DO_IF_TRACE(fprintf(stderr, "[%d] poolinit_bp(0x%X, %d)\n", PID, Pool, ObjAlignment)); +#endif DO_IF_PNP(++PoolsInited); // Track # pools initialized DO_IF_PNP(InitPrintNumPools()); } @@ -435,11 +435,11 @@ void pooldestroy_bp(PoolTy *Pool) { assert(Pool && "Null pool pointer passed in to pooldestroy!\n"); - unsigned PID; #ifdef ENABLE_POOL_IDS + unsigned PID; PID = removePoolNumber(Pool); -#endif DO_IF_TRACE(fprintf(stderr, "[%d] pooldestroy_bp", PID)); +#endif DO_IF_POOLDESTROY_STATS(PrintPoolStats(Pool)); // Free all allocated slabs. @@ -494,13 +494,13 @@ Pool->DeclaredSize = DeclaredSize; - unsigned PID; #ifdef ENABLE_POOL_IDS + unsigned PID; PID = addPoolNumber(Pool); -#endif DO_IF_TRACE(fprintf(stderr, "[%d] poolinit%s(0x%X, %d, %d)\n", PID, PoolTraits::getSuffix(), Pool, DeclaredSize, ObjAlignment)); +#endif DO_IF_PNP(++PoolsInited); // Track # pools initialized DO_IF_PNP(InitPrintNumPools()); } @@ -515,11 +515,11 @@ void pooldestroy(PoolTy *Pool) { assert(Pool && "Null pool pointer passed in to pooldestroy!\n"); - unsigned PID; #ifdef ENABLE_POOL_IDS + unsigned PID; PID = removePoolNumber(Pool); -#endif DO_IF_TRACE(fprintf(stderr, "[%d] pooldestroy", PID)); +#endif DO_IF_POOLDESTROY_STATS(PrintPoolStats(Pool)); // Free all allocated slabs. @@ -946,11 +946,11 @@ if (Pool->Slabs == 0) return; // no memory allocated from this pool. - unsigned PID; #ifdef ENABLE_POOL_IDS + unsigned PID; PID = removePoolNumber(Pool); -#endif DO_IF_TRACE(fprintf(stderr, "[%d] pooldestroy_pc", PID)); +#endif DO_IF_POOLDESTROY_STATS(PrintPoolStats(Pool)); // If there is space to remember this pool, do so. @@ -1028,7 +1028,6 @@ void poolaccesstrace(void *Ptr, void *PD) { static unsigned Time = ~0U; - static void *LastPtr = 0; // Not pool memory? if (PD == 0) return; Modified: poolalloc/trunk/tools/Pa/pa.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/tools/Pa/pa.cpp?rev=73769&r1=73768&r2=73769&view=diff ============================================================================== --- poolalloc/trunk/tools/Pa/pa.cpp (original) +++ poolalloc/trunk/tools/Pa/pa.cpp Fri Jun 19 12:03:36 2009 @@ -85,7 +85,6 @@ std::cerr << argv[0] << ": bytecode didn't read correctly.\n"; return 1; } - Module &mod = *M.get(); // Build up all of the passes that we want to do to the module... PassManager Passes; From resistor at mac.com Fri Jun 19 12:08:40 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 17:08:40 -0000 Subject: [llvm-commits] [llvm] r73770 - /llvm/trunk/include/llvm/System/Mutex.h Message-ID: <200906191708.n5JH8guv014852@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 12:08:20 2009 New Revision: 73770 URL: http://llvm.org/viewvc/llvm-project?rev=73770&view=rev Log: Fix a major typo. Nicolas, this is probably the cause of the failures you were seeing. Modified: llvm/trunk/include/llvm/System/Mutex.h Modified: llvm/trunk/include/llvm/System/Mutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Mutex.h?rev=73770&r1=73769&r2=73770&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Mutex.h (original) +++ llvm/trunk/include/llvm/System/Mutex.h Fri Jun 19 12:08:20 2009 @@ -89,7 +89,7 @@ explicit SmartMutex(bool recursive = true) : MutexImpl(recursive) { } bool acquire() { - if (!mt_only && llvm_is_multithreaded()) + if (!mt_only || llvm_is_multithreaded()) return MutexImpl::acquire(); return true; } From bob.wilson at apple.com Fri Jun 19 12:20:01 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 19 Jun 2009 17:20:01 -0000 Subject: [llvm-commits] [llvm] r73772 - /llvm/trunk/utils/NewNightlyTest.pl Message-ID: <200906191720.n5JHK4sc015582@zion.cs.uiuc.edu> Author: bwilson Date: Fri Jun 19 12:19:38 2009 New Revision: 73772 URL: http://llvm.org/viewvc/llvm-project?rev=73772&view=rev Log: Clean up nightly tester to use Perl's File::Find. Patch by Benjamin Kramer. Modified: llvm/trunk/utils/NewNightlyTest.pl Modified: llvm/trunk/utils/NewNightlyTest.pl URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/NewNightlyTest.pl?rev=73772&r1=73771&r2=73772&view=diff ============================================================================== --- llvm/trunk/utils/NewNightlyTest.pl (original) +++ llvm/trunk/utils/NewNightlyTest.pl Fri Jun 19 12:19:38 2009 @@ -1,6 +1,7 @@ #!/usr/bin/perl use POSIX qw(strftime); use File::Copy; +use File::Find; use Socket; # @@ -787,40 +788,20 @@ print "Organizing size of .o and .a files\n" if ( $VERBOSE ); ChangeDir( "$BuildDir/llvm", "Build Directory" ); - $afiles.= `find utils/ -iname '*.a' -ls`; - $afiles.= `find lib/ -iname '*.a' -ls`; - $afiles.= `find tools/ -iname '*.a' -ls`; - if($BUILDTYPE eq "release"){ - $afiles.= `find Release/ -iname '*.a' -ls`; - } elsif($BUILDTYPE eq "release-asserts") { - $afiles.= `find Release-Asserts/ -iname '*.a' -ls`; - } else { - $afiles.= `find Debug/ -iname '*.a' -ls`; - } - $ofiles.= `find utils/ -iname '*.o' -ls`; - $ofiles.= `find lib/ -iname '*.o' -ls`; - $ofiles.= `find tools/ -iname '*.o' -ls`; + my @dirs = ('utils', 'lib', 'tools'); if($BUILDTYPE eq "release"){ - $ofiles.= `find Release/ -iname '*.o' -ls`; + push @dirs, 'Release'; } elsif($BUILDTYPE eq "release-asserts") { - $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`; + push @dirs, 'Release-Asserts'; } else { - $ofiles.= `find Debug/ -iname '*.o' -ls`; + push @dirs, 'Debug'; } - @AFILES = split "\n", $afiles; - $a_file_sizes=""; - foreach $x (@AFILES){ - $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/; - $a_file_sizes.="$1 $2 $BUILDTYPE\n"; - } - @OFILES = split "\n", $ofiles; - $o_file_sizes=""; - foreach $x (@OFILES){ - $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/; - $o_file_sizes.="$1 $2 $BUILDTYPE\n"; - } + find(sub { + $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i; + $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i; + }, @dirs); } else { $a_file_sizes="No data due to a bad build."; $o_file_sizes="No data due to a bad build."; From resistor at mac.com Fri Jun 19 12:20:52 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 17:20:52 -0000 Subject: [llvm-commits] [llvm] r73773 - /llvm/trunk/lib/VMCore/Type.cpp Message-ID: <200906191720.n5JHKqL3015617@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 12:20:50 2009 New Revision: 73773 URL: http://llvm.org/viewvc/llvm-project?rev=73773&view=rev Log: Fix incorrect comment pointed out by Duncan. Modified: llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73773&r1=73772&r2=73773&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Fri Jun 19 12:20:50 2009 @@ -47,7 +47,7 @@ static ManagedStatic > TypeMapLock; // Recursive lock used for guarding access to AbstractTypeUsers. -// NOTE: The false template parameter means this will no-op when we're not in +// NOTE: The true template parameter means this will no-op when we're not in // multithreaded mode. static ManagedStatic > AbstractTypeUsersLock; From bob.wilson at apple.com Fri Jun 19 12:27:34 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 19 Jun 2009 10:27:34 -0700 Subject: [llvm-commits] [PATCH] Remove GNU particuliers from NewNightlyTest.pl , more system portable. In-Reply-To: References: Message-ID: <4E774752-2EA3-4168-8FE3-7BF8A407B780@apple.com> I've committed the patch. It worked fine on my tester, but one thing I noticed is that the file names submitted to the database before this patch had an extra slash in the paths, e.g., "Release//lib/ libLLVMCore.a". Now that extra slash is gone. The nightly tester website will think they are different files -- it's not very smart -- so the changes in file size will not be reported between yesterday and today. On Jun 18, 2009, at 11:43 AM, Bob Wilson wrote: > Nice cleanup. Thanks, Benjamin. I'm going to try it out with my > nightly tester. If everything goes well, I'll commit your patch > tomorrow. > > On Jun 18, 2009, at 4:31 AM, Benjamin Kramer wrote: > >> Sorry, but seeing this ugly perl code almost made my cry (not your >> fault though). So I decided to port it to File::Find which is part >> of perl's standard library. >> >> This gives us some advantages: >> 1. portability: File::Find works even on windows ;) >> 2. performance: the new code is >100 times faster on my machine. The >> slowdown is probably caused by backtracking in the old regex >> 3. cleanup: there were lots of duplicated code >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Fri Jun 19 12:33:55 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Jun 2009 17:33:55 -0000 Subject: [llvm-commits] [llvm] r73774 - in /llvm/trunk: lib/Analysis/IVUsers.cpp test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll Message-ID: <200906191733.n5JHXvBX016085@zion.cs.uiuc.edu> Author: djg Date: Fri Jun 19 12:33:15 2009 New Revision: 73774 URL: http://llvm.org/viewvc/llvm-project?rev=73774&view=rev Log: Don't (unconditionally) use getSCEVAtScope to simplify the step expression in IVUsers, because in the case of a use of a non-linear addrec outside of a loop, this causes the addrec to be evaluated as a linear addrec. Added: llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll Modified: llvm/trunk/lib/Analysis/IVUsers.cpp Modified: llvm/trunk/lib/Analysis/IVUsers.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IVUsers.cpp?rev=73774&r1=73773&r2=73774&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IVUsers.cpp (original) +++ llvm/trunk/lib/Analysis/IVUsers.cpp Fri Jun 19 12:33:15 2009 @@ -112,7 +112,6 @@ SCEVHandle AddRecStart = AddRec->getStart(); AddRecStart = SE->getSCEVAtScope(AddRecStart, UseLoop); SCEVHandle AddRecStride = AddRec->getStepRecurrence(*SE); - AddRecStride = SE->getSCEVAtScope(AddRecStride, UseLoop); // FIXME: If Start contains an SCEVAddRecExpr from a different loop, other // than an outer loop of the current loop, reject it. LSR has no concept of Added: llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll?rev=73774&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll (added) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll Fri Jun 19 12:33:15 2009 @@ -0,0 +1,18 @@ +; RUN: llvm-as < %s | opt -analyze -iv-users -disable-output | grep {Stride i64 {1,+,2}:} + +; The value of %r is dependent on a polynomial iteration expression. + +define i64 @foo(i64 %n) { +entry: + br label %loop + +loop: + %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %loop ] + %indvar.next = add i64 %indvar, 1 + %c = icmp eq i64 %indvar.next, %n + br i1 %c, label %exit, label %loop + +exit: + %r = mul i64 %indvar, %indvar + ret i64 %r +} From resistor at mac.com Fri Jun 19 12:45:33 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 17:45:33 -0000 Subject: [llvm-commits] [llvm] r73775 - in /llvm/trunk/lib/VMCore: Pass.cpp Type.cpp Message-ID: <200906191745.n5JHjdrT016449@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 12:45:12 2009 New Revision: 73775 URL: http://llvm.org/viewvc/llvm-project?rev=73775&view=rev Log: Move the memory fences out of the path for single-threaded mode. Modified: llvm/trunk/lib/VMCore/Pass.cpp llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=73775&r1=73774&r2=73775&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Fri Jun 19 12:45:12 2009 @@ -198,9 +198,9 @@ // Use double-checked locking to safely initialize the registrar when // we're running in multithreaded mode. PassRegistrar* tmp = PassRegistrarObj; - sys::MemoryFence(); - if (!tmp) { - if (llvm_is_multithreaded()) { + if (llvm_is_multithreaded()) { + sys::MemoryFence(); + if (!tmp) { llvm_acquire_global_lock(); tmp = PassRegistrarObj; if (!tmp) { @@ -209,10 +209,11 @@ PassRegistrarObj = tmp; } llvm_release_global_lock(); - } else { - PassRegistrarObj = new PassRegistrar(); } + } else if (!tmp) { + PassRegistrarObj = new PassRegistrar(); } + return PassRegistrarObj; } Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73775&r1=73774&r2=73775&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Fri Jun 19 12:45:12 2009 @@ -458,9 +458,9 @@ static Type *AlwaysOpaqueTy = 0; static PATypeHolder* Holder = 0; Type *tmp = AlwaysOpaqueTy; - sys::MemoryFence(); - if (!tmp) { - if (llvm_is_multithreaded()) { + if (llvm_is_multithreaded()) { + sys::MemoryFence(); + if (!tmp) { llvm_acquire_global_lock(); tmp = AlwaysOpaqueTy; if (!tmp) { @@ -472,12 +472,12 @@ } llvm_release_global_lock(); - } else { - AlwaysOpaqueTy = OpaqueType::get(); - Holder = new PATypeHolder(AlwaysOpaqueTy); - } - } - + } + } else { + AlwaysOpaqueTy = OpaqueType::get(); + Holder = new PATypeHolder(AlwaysOpaqueTy); + } + ContainedTys[0] = AlwaysOpaqueTy; // Change the rest of the types to be Int32Ty's. It doesn't matter what we From gohman at apple.com Fri Jun 19 12:49:54 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Jun 2009 17:49:54 -0000 Subject: [llvm-commits] [llvm] r73776 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200906191749.n5JHnsdD016579@zion.cs.uiuc.edu> Author: djg Date: Fri Jun 19 12:49:54 2009 New Revision: 73776 URL: http://llvm.org/viewvc/llvm-project?rev=73776&view=rev Log: Make ScalarEvolution::print print getSCEVAtScope values for expressions, when interesting. 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=73776&r1=73775&r2=73776&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Jun 19 12:49:54 2009 @@ -4048,9 +4048,17 @@ SCEVHandle SV = SE.getSCEV(&*I); SV->print(OS); - if (const Loop *L = LI->getLoopFor((*I).getParent())) { + const Loop *L = LI->getLoopFor((*I).getParent()); + + SCEVHandle AtUse = SE.getSCEVAtScope(SV, L); + if (AtUse != SV) { + OS << " --> "; + AtUse->print(OS); + } + + if (L) { OS << "\t\t" "Exits: "; - SCEVHandle ExitValue = SE.getSCEVAtScope(&*I, L->getParentLoop()); + SCEVHandle ExitValue = SE.getSCEVAtScope(SV, L->getParentLoop()); if (!ExitValue->isLoopInvariant(L)) { OS << "<>"; } else { From resistor at mac.com Fri Jun 19 12:50:12 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 17:50:12 -0000 Subject: [llvm-commits] [llvm] r73777 - /llvm/trunk/include/llvm/Support/ManagedStatic.h Message-ID: <200906191750.n5JHoCgr016604@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 12:50:11 2009 New Revision: 73777 URL: http://llvm.org/viewvc/llvm-project?rev=73777&view=rev Log: Fences are expensive. Avoid doing them when we're not in multithreaded mode. Modified: llvm/trunk/include/llvm/Support/ManagedStatic.h Modified: llvm/trunk/include/llvm/Support/ManagedStatic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ManagedStatic.h?rev=73777&r1=73776&r2=73777&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ManagedStatic.h (original) +++ llvm/trunk/include/llvm/Support/ManagedStatic.h Fri Jun 19 12:50:11 2009 @@ -61,28 +61,28 @@ // Accessors. C &operator*() { void* tmp = Ptr; - sys::MemoryFence(); + if (llvm_is_multithreaded()) sys::MemoryFence(); if (!tmp) RegisterManagedStatic(object_creator, object_deleter); return *static_cast(Ptr); } C *operator->() { void* tmp = Ptr; - sys::MemoryFence(); + if (llvm_is_multithreaded()) sys::MemoryFence(); if (!tmp) RegisterManagedStatic(object_creator, object_deleter); return static_cast(Ptr); } const C &operator*() const { void* tmp = Ptr; - sys::MemoryFence(); + if (llvm_is_multithreaded()) sys::MemoryFence(); if (!tmp) RegisterManagedStatic(object_creator, object_deleter); return *static_cast(Ptr); } const C *operator->() const { void* tmp = Ptr; - sys::MemoryFence(); + if (llvm_is_multithreaded()) sys::MemoryFence(); if (!tmp) RegisterManagedStatic(object_creator, object_deleter); return static_cast(Ptr); From baldrick at free.fr Fri Jun 19 13:03:07 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 19 Jun 2009 20:03:07 +0200 Subject: [llvm-commits] Cyclic dependencies between LLVM libraries with debug builds In-Reply-To: <4A76F22F-EC35-46AE-AC3D-8E12FC5F9A49@apple.com> References: <4A3A14AA.4020105@free.fr> <4A3B5CCD.8040705@free.fr> <4A76F22F-EC35-46AE-AC3D-8E12FC5F9A49@apple.com> Message-ID: <4A3BD2DB.3000607@free.fr> Hi Chris, > Well that's definitely a problem. r73767 should fix this, I wonder > why I don't see this. :( yup, that fixes sparc, thanks. But there's still find-cycles.pl: Circular dependency between *.a files: find-cycles.pl: libLLVMCellSPUAsmPrinter.a libLLVMCellSPUCodeGen.a find-cycles.pl: Circular dependency between *.a files: find-cycles.pl: libLLVMAlphaAsmPrinter.a libLLVMAlphaCodeGen.a find-cycles.pl: Circular dependency between *.a files: find-cycles.pl: libLLVMIA64AsmPrinter.a libLLVMIA64CodeGen.a As far why you don't see it, does reverting the attached patch help? Ciao, Duncan. -------------- next part -------------- A non-text attachment was scrubbed... Name: nm.diff Type: text/x-patch Size: 1038 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090619/8f550ba1/attachment.bin From lattner at apple.com Fri Jun 19 13:30:45 2009 From: lattner at apple.com (Tanya Lattner) Date: Fri, 19 Jun 2009 11:30:45 -0700 Subject: [llvm-commits] [PATCH] Remove GNU particuliers from NewNightlyTest.pl , more system portable. In-Reply-To: <4E774752-2EA3-4168-8FE3-7BF8A407B780@apple.com> References: <4E774752-2EA3-4168-8FE3-7BF8A407B780@apple.com> Message-ID: <5D8096DF-4780-408D-B247-CADA29B04579@apple.com> On Jun 19, 2009, at 10:27 AM, Bob Wilson wrote: > I've committed the patch. It worked fine on my tester, but one thing > I noticed is that the file names submitted to the database before this > patch had an extra slash in the paths, e.g., "Release//lib/ > libLLVMCore.a". Now that extra slash is gone. The nightly tester > website will think they are different files -- it's not very smart -- > so the changes in file size will not be reported between yesterday and > today. > Actually it is pretty important. I'm pretty sure this will break past results. So look at the graphs.. you will only see so far back. I know its true with the new nightly tester database since we have a table with filenames. -Tanya > On Jun 18, 2009, at 11:43 AM, Bob Wilson wrote: > >> Nice cleanup. Thanks, Benjamin. I'm going to try it out with my >> nightly tester. If everything goes well, I'll commit your patch >> tomorrow. >> >> On Jun 18, 2009, at 4:31 AM, Benjamin Kramer wrote: >> >>> Sorry, but seeing this ugly perl code almost made my cry (not your >>> fault though). So I decided to port it to File::Find which is part >>> of perl's standard library. >>> >>> This gives us some advantages: >>> 1. portability: File::Find works even on windows ;) >>> 2. performance: the new code is >100 times faster on my machine. The >>> slowdown is probably caused by backtracking in the old regex >>> 3. cleanup: there were lots of duplicated code >>> >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090619/b3b531fe/attachment.html From resistor at mac.com Fri Jun 19 13:34:16 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 18:34:16 -0000 Subject: [llvm-commits] [llvm] r73778 - /llvm/trunk/lib/VMCore/Constants.cpp Message-ID: <200906191834.n5JIYIRf018222@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 13:34:09 2009 New Revision: 73778 URL: http://llvm.org/viewvc/llvm-project?rev=73778&view=rev Log: Forgot to remove some explicit locking when it became implicit in the ValueMap. Modified: llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73778&r1=73777&r2=73778&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Fri Jun 19 13:34:09 2009 @@ -1473,6 +1473,7 @@ /// destroyConstant - Remove the constant from the constant table... /// void ConstantArray::destroyConstant() { + // Implicitly locked. ArrayConstants->remove(this); destroyConstantImpl(); } @@ -1601,6 +1602,7 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantStruct::destroyConstant() { + // Implicitly locked. StructConstants->remove(this); destroyConstantImpl(); } @@ -1668,7 +1670,7 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantVector::destroyConstant() { - sys::SmartScopedWriter Write(&*ConstantsLock); + // Implicitly locked. VectorConstants->remove(this); destroyConstantImpl(); } @@ -1740,7 +1742,7 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantPointerNull::destroyConstant() { - sys::SmartScopedWriter Writer(&*ConstantsLock); + // Implicitly locked. NullPtrConstants->remove(this); destroyConstantImpl(); } @@ -2721,7 +2723,7 @@ // destroyConstant - Remove the constant from the constant table... // void ConstantExpr::destroyConstant() { - sys::SmartScopedWriter Writer(&*ConstantsLock); + // Implicitly locked. ExprConstants->remove(this); destroyConstantImpl(); } From resistor at mac.com Fri Jun 19 13:37:51 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 18:37:51 -0000 Subject: [llvm-commits] [llvm] r73779 - /llvm/trunk/lib/System/Atomic.cpp Message-ID: <200906191837.n5JIbpeR018380@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 13:37:50 2009 New Revision: 73779 URL: http://llvm.org/viewvc/llvm-project?rev=73779&view=rev Log: Fix bad paste-o in the MSVC atomics. Patch by ???????? ??????????????. Modified: llvm/trunk/lib/System/Atomic.cpp Modified: llvm/trunk/lib/System/Atomic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Atomic.cpp?rev=73779&r1=73778&r2=73779&view=diff ============================================================================== --- llvm/trunk/lib/System/Atomic.cpp (original) +++ llvm/trunk/lib/System/Atomic.cpp Fri Jun 19 13:37:50 2009 @@ -59,7 +59,7 @@ #elif defined(__GNUC__) return __sync_add_and_fetch(ptr, 1); #elif defined(_MSC_VER) - return InterlockedCompareExchange(ptr, new_value, old_value); + return InterlockedIncrement(ptr); #else # error No atomic increment implementation for your platform! #endif @@ -72,7 +72,7 @@ #elif defined(__GNUC__) return __sync_sub_and_fetch(ptr, 1); #elif defined(_MSC_VER) - return InterlockedIncrement(ptr); + return InterlockedDecrement(ptr); #else # error No atomic decrement implementation for your platform! #endif From resistor at mac.com Fri Jun 19 13:50:59 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 11:50:59 -0700 Subject: [llvm-commits] [llvm] r73779 - /llvm/trunk/lib/System/Atomic.cpp In-Reply-To: <200906191837.n5JIbpeR018380@zion.cs.uiuc.edu> References: <200906191837.n5JIbpeR018380@zion.cs.uiuc.edu> Message-ID: <29D2B590-4663-4D7B-863A-5D1C4C4B99AD@mac.com> On Jun 19, 2009, at 11:37 AM, Owen Anderson wrote: > Patch by ???????? ??????????????. Apparently it should be written Ivan Sorokin, in Latin characters. Sorry Ivan! --Owen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090619/8fb2c586/attachment.html From gohman at apple.com Fri Jun 19 14:02:43 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Jun 2009 12:02:43 -0700 Subject: [llvm-commits] [llvm] r73401 - /llvm/trunk/lib/Analysis/IVUsers.cpp In-Reply-To: <4A3B0AC3.2060509@microchip.com> References: <200906151838.n5FIcxns002287@zion.cs.uiuc.edu> <4A39F352.9090003@microchip.com> <4A3B0AC3.2060509@microchip.com> Message-ID: <06EFF69E-8B8A-4D00-9954-12F582001F9B@apple.com> On Jun 18, 2009, at 8:49 PM, Sanjiv Gupta wrote: > > >>>> >>>> >>>> >>>> >>>> + AddRecStart = SE->getSCEVAtScope(AddRecStart, UseLoop); >>>> >>>> >>>> >>>> + SCEVHandle AddRecStride = AddRec->getStepRecurrence(*SE); >>>> >>>> >>>> >>>> + AddRecStride = SE->getSCEVAtScope(AddRecStride, UseLoop); >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>> Dan, >>> >>> >>> >>> Since you meant only code cleanup, the last line I think is left >>> there by mistake as in the original code we had only one call to >>> >>> >>> >>> SE->getSCEVAtScope(AddRecStart, UseLoop); which is already there >>> two lines above. >>> >> >> >> Hmm, you're right that this wasn't pure cleanup. This commit is a >> >> change I had split out from a larger patch, and I missed that detail. >> >> The call isn't redundant though; the first call is doing >> getSCEVAtScope >> >> for the Start expression, and the second is doing it for the Stride >> >> expression. This probably isn't especially valuable at the moment, >> >> but it shouldn't cause trouble. >> >> >> >> Dan >> >> >> > It is causing trouble. Few of our test cases broke. They run fine if > I remove the last call though. I looked at this, and indeed found a problem. I fixed it with r73774. Thanks, Dan From bob.wilson at apple.com Fri Jun 19 14:04:46 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 19 Jun 2009 12:04:46 -0700 Subject: [llvm-commits] [PATCH] Remove GNU particuliers from NewNightlyTest.pl , more system portable. In-Reply-To: <5D8096DF-4780-408D-B247-CADA29B04579@apple.com> References: <4E774752-2EA3-4168-8FE3-7BF8A407B780@apple.com> <5D8096DF-4780-408D-B247-CADA29B04579@apple.com> Message-ID: On Jun 19, 2009, at 11:30 AM, Tanya Lattner wrote: > > On Jun 19, 2009, at 10:27 AM, Bob Wilson wrote: > >> I've committed the patch. It worked fine on my tester, but one thing >> I noticed is that the file names submitted to the database before >> this >> patch had an extra slash in the paths, e.g., "Release//lib/ >> libLLVMCore.a". Now that extra slash is gone. The nightly tester >> website will think they are different files -- it's not very smart -- >> so the changes in file size will not be reported between yesterday >> and >> today. >> > > Actually it is pretty important. I'm pretty sure this will break > past results. So look at the graphs.. you will only see so far back. > I know its true with the new nightly tester database since we have a > table with filenames. With the "old" nightly server, I am unable to look at the graphs. In fact, for at least the last few months, I've been unable to view ANY pages from it. Every attempt times out. With the "new" server, I can look at results and see the changes in file sizes, but if I try to see display a graph, I get this error: "The requested URL /nightlytest2/individualfilesizegraph.php was not found on this server." So, do you think we need to do something about this problem? I suppose the database query needs to ignore extras slashes in file names, but I don't know how to do that. I was hoping it would be OK to have a discontinuity in the file size histories. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090619/56ae1f1a/attachment.html From criswell at uiuc.edu Fri Jun 19 14:17:27 2009 From: criswell at uiuc.edu (John Criswell) Date: Fri, 19 Jun 2009 19:17:27 -0000 Subject: [llvm-commits] [poolalloc] r73780 - /poolalloc/trunk/include/poolalloc/MMAPSupport.h Message-ID: <200906191917.n5JJHSSb019980@zion.cs.uiuc.edu> Author: criswell Date: Fri Jun 19 14:17:21 2009 New Revision: 73780 URL: http://llvm.org/viewvc/llvm-project?rev=73780&view=rev Log: Made a function static and inline to silence compiler warning errors. Modified: poolalloc/trunk/include/poolalloc/MMAPSupport.h Modified: poolalloc/trunk/include/poolalloc/MMAPSupport.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/MMAPSupport.h?rev=73780&r1=73779&r2=73780&view=diff ============================================================================== --- poolalloc/trunk/include/poolalloc/MMAPSupport.h (original) +++ poolalloc/trunk/include/poolalloc/MMAPSupport.h Fri Jun 19 14:17:21 2009 @@ -32,7 +32,8 @@ #define MAP_ANONYMOUS MAP_ANON #endif /* defined(MAP_ANON) && !defined(MAP_ANONYMOUS) */ -static void *AllocateSpaceWithMMAP(size_t Size, bool UseNoReserve = false) { +static inline void * +AllocateSpaceWithMMAP(size_t Size, bool UseNoReserve = false) { // NOTE: this assumes Size is a multiple of the page size. int FD = -1; #ifdef NEED_DEV_ZERO_FOR_MMAP From asl at math.spbu.ru Fri Jun 19 14:37:05 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Fri, 19 Jun 2009 19:37:05 -0000 Subject: [llvm-commits] [llvm] r73781 - in /llvm/trunk/lib/Target: Alpha/AlphaTargetMachine.cpp Alpha/AlphaTargetMachine.h Alpha/AsmPrinter/AlphaAsmPrinter.cpp CellSPU/AsmPrinter/SPUAsmPrinter.cpp CellSPU/SPUTargetMachine.cpp CellSPU/SPUTargetMachine.h IA64/AsmPrinter/IA64AsmPrinter.cpp IA64/IA64TargetMachine.cpp IA64/IA64TargetMachine.h Message-ID: <200906191937.n5JJb7Iu020707@zion.cs.uiuc.edu> Author: asl Date: Fri Jun 19 14:36:55 2009 New Revision: 73781 URL: http://llvm.org/viewvc/llvm-project?rev=73781&view=rev Log: Unbreak cyclic deps Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.h llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp llvm/trunk/lib/Target/IA64/IA64TargetMachine.h Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp?rev=73781&r1=73780&r2=73781&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.cpp Fri Jun 19 14:36:55 2009 @@ -21,16 +21,12 @@ using namespace llvm; -/// AlphaTargetMachineModule - Note that this is used on hosts that cannot link -/// in a library unless there are references into the library. In particular, -/// it seems that it is not possible to get things to work on Win32 without -/// this. Though it is unused, do not remove it. -extern "C" int AlphaTargetMachineModule; -int AlphaTargetMachineModule = 0; - // Register the targets static RegisterTarget X("alpha", "Alpha [experimental]"); +// No assembler printer by default +AlphaTargetMachine::AsmPrinterCtorFn AlphaTargetMachine::AsmPrinterCtor = 0; + // Force static initialization when called from llvm/InitializeAllTargets.h namespace llvm { void InitializeAlphaTarget() { } @@ -97,23 +93,32 @@ bool Verbose, raw_ostream &Out) { PM.add(createAlphaLLRPPass(*this)); - PM.add(createAlphaCodePrinterPass(Out, *this, OptLevel, Verbose)); + // Output assembly language. + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(Out, *this, OptLevel, Verbose)); return false; } bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, MachineCodeEmitter &MCE) { PM.add(createAlphaCodeEmitterPass(*this, MCE)); - if (DumpAsm) - PM.add(createAlphaCodePrinterPass(errs(), *this, OptLevel, true)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(errs(), *this, OptLevel, true)); + } return false; } bool AlphaTargetMachine::addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool DumpAsm, JITCodeEmitter &JCE) { PM.add(createAlphaJITCodeEmitterPass(*this, JCE)); - if (DumpAsm) - PM.add(createAlphaCodePrinterPass(errs(), *this, OptLevel, true)); + if (DumpAsm) { + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(errs(), *this, OptLevel, true)); + } return false; } bool AlphaTargetMachine::addSimpleCodeEmitter(PassManagerBase &PM, Modified: llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h?rev=73781&r1=73780&r2=73781&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h (original) +++ llvm/trunk/lib/Target/Alpha/AlphaTargetMachine.h Fri Jun 19 14:36:55 2009 @@ -33,10 +33,18 @@ AlphaJITInfo JITInfo; AlphaSubtarget Subtarget; AlphaTargetLowering TLInfo; - + protected: virtual const TargetAsmInfo *createTargetAsmInfo() const; - + + // To avoid having target depend on the asmprinter stuff libraries, asmprinter + // set this functions to ctor pointer at startup time if they are linked in. + typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o, + TargetMachine &tm, + CodeGenOpt::Level OptLevel, + bool verbose); + static AsmPrinterCtorFn AsmPrinterCtor; + public: AlphaTargetMachine(const Module &M, const std::string &FS); @@ -46,7 +54,7 @@ virtual const AlphaRegisterInfo *getRegisterInfo() const { return &InstrInfo.getRegisterInfo(); } - virtual AlphaTargetLowering* getTargetLowering() const { + virtual AlphaTargetLowering* getTargetLowering() const { return const_cast(&TLInfo); } virtual const TargetData *getTargetData() const { return &DataLayout; } @@ -56,7 +64,7 @@ static unsigned getJITMatchQuality(); static unsigned getModuleMatchQuality(const Module &M); - + // Pass Pipeline Configuration virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel); virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel); @@ -75,6 +83,10 @@ CodeGenOpt::Level OptLevel, bool DumpAsm, JITCodeEmitter &JCE); + + static void registerAsmPrinter(AsmPrinterCtorFn F) { + AsmPrinterCtor = F; + } }; } // end namespace llvm Modified: llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp?rev=73781&r1=73780&r2=73781&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp Fri Jun 19 14:36:55 2009 @@ -309,3 +309,11 @@ namespace llvm { void InitializeAlphaAsmPrinter() { } } + +namespace { + static struct Register { + Register() { + AlphaTargetMachine::registerAsmPrinter(createAlphaCodePrinterPass); + } + } Registrator; +} Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=73781&r1=73780&r2=73781&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Fri Jun 19 14:36:55 2009 @@ -627,3 +627,11 @@ namespace llvm { void InitializeCellSPUAsmPrinter() { } } + +namespace { + static struct Register { + Register() { + SPUTargetMachine::registerAsmPrinter(createSPUAsmPrinterPass); + } + } Registrator; +} Modified: llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp?rev=73781&r1=73780&r2=73781&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp Fri Jun 19 14:36:55 2009 @@ -23,20 +23,15 @@ using namespace llvm; -/// CellSPUTargetMachineModule - Note that this is used on hosts that -/// cannot link in a library unless there are references into the -/// library. In particular, it seems that it is not possible to get -/// things to work on Win32 without this. Though it is unused, do not -/// remove it. -extern "C" int CellSPUTargetMachineModule; -int CellSPUTargetMachineModule = 0; - namespace { // Register the targets RegisterTarget CELLSPU("cellspu", "STI CBEA Cell SPU [experimental]"); } +// No assembler printer by default +SPUTargetMachine::AsmPrinterCtorFn SPUTargetMachine::AsmPrinterCtor = 0; + // Force static initialization when called from llvm/InitializeAllTargets.h namespace llvm { void InitializeCellSPUTarget() { } @@ -98,6 +93,9 @@ CodeGenOpt::Level OptLevel, bool Verbose, raw_ostream &Out) { - PM.add(createSPUAsmPrinterPass(Out, *this, OptLevel, Verbose)); + // Output assembly language. + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(Out, *this, OptLevel, Verbose)); return false; } Modified: llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.h?rev=73781&r1=73780&r2=73781&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.h (original) +++ llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.h Fri Jun 19 14:36:55 2009 @@ -35,10 +35,18 @@ SPUFrameInfo FrameInfo; SPUTargetLowering TLInfo; InstrItineraryData InstrItins; - + protected: virtual const TargetAsmInfo *createTargetAsmInfo() const; - + + // To avoid having target depend on the asmprinter stuff libraries, asmprinter + // set this functions to ctor pointer at startup time if they are linked in. + typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o, + SPUTargetMachine &tm, + CodeGenOpt::Level OptLevel, + bool verbose); + static AsmPrinterCtorFn AsmPrinterCtor; + public: SPUTargetMachine(const Module &M, const std::string &FS); @@ -78,7 +86,7 @@ return &DataLayout; } - virtual const InstrItineraryData getInstrItineraryData() const { + virtual const InstrItineraryData getInstrItineraryData() const { return InstrItins; } @@ -88,6 +96,10 @@ virtual bool addAssemblyEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool Verbose, raw_ostream &Out); + + static void registerAsmPrinter(AsmPrinterCtorFn F) { + AsmPrinterCtor = F; + } }; } // end namespace llvm Modified: llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp?rev=73781&r1=73780&r2=73781&view=diff ============================================================================== --- llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp Fri Jun 19 14:36:55 2009 @@ -375,6 +375,15 @@ return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo(), OptLevel, verbose); } +namespace { + static struct Register { + Register() { + IA64TargetMachine::registerAsmPrinter(createIA64CodePrinterPass); + } + } Registrator; +} + + // Force static initialization when called from // llvm/InitializeAllAsmPrinters.h namespace llvm { Modified: llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp?rev=73781&r1=73780&r2=73781&view=diff ============================================================================== --- llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/IA64/IA64TargetMachine.cpp Fri Jun 19 14:36:55 2009 @@ -19,16 +19,13 @@ #include "llvm/Target/TargetMachineRegistry.h" using namespace llvm; -/// IA64TargetMachineModule - Note that this is used on hosts that cannot link -/// in a library unless there are references into the library. In particular, -/// it seems that it is not possible to get things to work on Win32 without -/// this. Though it is unused, do not remove it. -extern "C" int IA64TargetMachineModule; -int IA64TargetMachineModule = 0; - -static RegisterTarget X("ia64", +// Register the target +static RegisterTarget X("ia64", "IA-64 (Itanium) [experimental]"); +// No assembler printer by default +IA64TargetMachine::AsmPrinterCtorFn IA64TargetMachine::AsmPrinterCtor = 0; + // Force static initialization when called from llvm/InitializeAllTargets.h namespace llvm { void InitializeIA64Target() { } @@ -93,7 +90,10 @@ CodeGenOpt::Level OptLevel, bool Verbose, raw_ostream &Out) { - PM.add(createIA64CodePrinterPass(Out, *this, OptLevel, Verbose)); + // Output assembly language. + assert(AsmPrinterCtor && "AsmPrinter was not linked in"); + if (AsmPrinterCtor) + PM.add(AsmPrinterCtor(Out, *this, OptLevel, Verbose)); return false; } Modified: llvm/trunk/lib/Target/IA64/IA64TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/IA64/IA64TargetMachine.h?rev=73781&r1=73780&r2=73781&view=diff ============================================================================== --- llvm/trunk/lib/Target/IA64/IA64TargetMachine.h (original) +++ llvm/trunk/lib/Target/IA64/IA64TargetMachine.h Fri Jun 19 14:36:55 2009 @@ -30,24 +30,32 @@ TargetFrameInfo FrameInfo; //IA64JITInfo JITInfo; IA64TargetLowering TLInfo; - + protected: virtual const TargetAsmInfo *createTargetAsmInfo() const; + // To avoid having target depend on the asmprinter stuff libraries, asmprinter + // set this functions to ctor pointer at startup time if they are linked in. + typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o, + IA64TargetMachine &tm, + CodeGenOpt::Level OptLevel, + bool verbose); + static AsmPrinterCtorFn AsmPrinterCtor; + public: IA64TargetMachine(const Module &M, const std::string &FS); virtual const IA64InstrInfo *getInstrInfo() const { return &InstrInfo; } virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; } virtual const IA64Subtarget *getSubtargetImpl() const { return &Subtarget; } - virtual IA64TargetLowering *getTargetLowering() const { + virtual IA64TargetLowering *getTargetLowering() const { return const_cast(&TLInfo); } virtual const IA64RegisterInfo *getRegisterInfo() const { return &InstrInfo.getRegisterInfo(); } virtual const TargetData *getTargetData() const { return &DataLayout; } - + static unsigned getModuleMatchQuality(const Module &M); // Pass Pipeline Configuration @@ -56,6 +64,10 @@ virtual bool addAssemblyEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, bool Verbose, raw_ostream &Out); + + static void registerAsmPrinter(AsmPrinterCtorFn F) { + AsmPrinterCtor = F; + } }; } // End llvm namespace From lattner at apple.com Fri Jun 19 14:42:43 2009 From: lattner at apple.com (Tanya Lattner) Date: Fri, 19 Jun 2009 12:42:43 -0700 Subject: [llvm-commits] [PATCH] Remove GNU particuliers from NewNightlyTest.pl , more system portable. In-Reply-To: References: <4E774752-2EA3-4168-8FE3-7BF8A407B780@apple.com> <5D8096DF-4780-408D-B247-CADA29B04579@apple.com> Message-ID: <5F333418-F456-45B5-81A2-08B53F4FE95D@apple.com> On Jun 19, 2009, at 12:04 PM, Bob Wilson wrote: > > On Jun 19, 2009, at 11:30 AM, Tanya Lattner wrote: > >> >> On Jun 19, 2009, at 10:27 AM, Bob Wilson wrote: >> >>> I've committed the patch. It worked fine on my tester, but one >>> thing >>> I noticed is that the file names submitted to the database before >>> this >>> patch had an extra slash in the paths, e.g., "Release//lib/ >>> libLLVMCore.a". Now that extra slash is gone. The nightly tester >>> website will think they are different files -- it's not very smart >>> -- >>> so the changes in file size will not be reported between yesterday >>> and >>> today. >>> >> >> Actually it is pretty important. I'm pretty sure this will break >> past results. So look at the graphs.. you will only see so far >> back. I know its true with the new nightly tester database since we >> have a table with filenames. > > > With the "old" nightly server, I am unable to look at the graphs. > In fact, for at least the last few months, I've been unable to view > ANY pages from it. Every attempt times out. > Cute. Not sure why that would be. > With the "new" server, I can look at results and see the changes in > file sizes, but if I try to see display a graph, I get this error: > "The requested URL /nightlytest2/individualfilesizegraph.php was not > found on this server." > Yeah, it doesn't exist :) If it did, it wouldn't work because of the filename change. This is part of the missing features of the new one. > So, do you think we need to do something about this problem? I > suppose the database query needs to ignore extras slashes in file > names, but I don't know how to do that. I was hoping it would be OK > to have a discontinuity in the file size histories. > It probably should be fixed in the DB. However, Daniel is supposed to have a new tester infrastructure. It would be nice to move everyone over to it. I'm not sure what DB schema he is using. -Tanya > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090619/3b465b64/attachment.html From clattner at apple.com Fri Jun 19 14:56:49 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 19 Jun 2009 12:56:49 -0700 Subject: [llvm-commits] [llvm] r73781 - in /llvm/trunk/lib/Target: Alpha/AlphaTargetMachine.cpp Alpha/AlphaTargetMachine.h Alpha/AsmPrinter/AlphaAsmPrinter.cpp CellSPU/AsmPrinter/SPUAsmPrinter.cpp CellSPU/SPUTargetMachine.cpp CellSPU/SPUTargetMachine.h IA64/AsmPrinter/IA64AsmPrinter.cpp IA64/IA64TargetMachine.cpp IA64/IA64TargetMachine.h In-Reply-To: <200906191937.n5JJb7Iu020707@zion.cs.uiuc.edu> References: <200906191937.n5JJb7Iu020707@zion.cs.uiuc.edu> Message-ID: <7C674228-2DCC-4A31-B6AA-AFD2EC4D4778@apple.com> On Jun 19, 2009, at 12:37 PM, Anton Korobeynikov wrote: > Author: asl > Date: Fri Jun 19 14:36:55 2009 > New Revision: 73781 > > URL: http://llvm.org/viewvc/llvm-project?rev=73781&view=rev > Log: > Unbreak cyclic deps Wow, thanks Anton! -Chris From evan.cheng at apple.com Fri Jun 19 16:15:06 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 19 Jun 2009 21:15:06 -0000 Subject: [llvm-commits] [llvm] r73783 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/optimize-max-0.ll test/CodeGen/X86/optimize-max-1.ll Message-ID: <200906192115.n5JLF7bq024280@zion.cs.uiuc.edu> Author: evancheng Date: Fri Jun 19 16:15:06 2009 New Revision: 73783 URL: http://llvm.org/viewvc/llvm-project?rev=73783&view=rev Log: Revert 73718. It's breaking 254.gap. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp llvm/trunk/test/CodeGen/X86/optimize-max-0.ll llvm/trunk/test/CodeGen/X86/optimize-max-1.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=73783&r1=73782&r2=73783&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Jun 19 16:15:06 2009 @@ -143,10 +143,10 @@ /// inside the loop then try to eliminate the cast opeation. void OptimizeShadowIV(Loop *L); - /// OptimizeMax - Rewrite the loop's terminating condition - /// if it uses a max computation. - ICmpInst *OptimizeMax(Loop *L, ICmpInst *Cond, - IVStrideUse* &CondUse); + /// OptimizeSMax - Rewrite the loop's terminating condition + /// if it uses an smax computation. + ICmpInst *OptimizeSMax(Loop *L, ICmpInst *Cond, + IVStrideUse* &CondUse); bool FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse, const SCEVHandle *&CondStride); @@ -2044,8 +2044,8 @@ return Cond; } -/// OptimizeMax - Rewrite the loop's terminating condition if it uses -/// a max computation. +/// OptimizeSMax - Rewrite the loop's terminating condition if it uses +/// an smax computation. /// /// This is a narrow solution to a specific, but acute, problem. For loops /// like this: @@ -2055,10 +2055,10 @@ /// p[i] = 0.0; /// } while (++i < n); /// -/// the trip count isn't just 'n', because 'n' might not be positive. And -/// unfortunately this can come up even for loops where the user didn't use -/// a C do-while loop. For example, seemingly well-behaved top-test loops -/// will commonly be lowered like this: +/// where the comparison is signed, the trip count isn't just 'n', because +/// 'n' could be negative. And unfortunately this can come up even for loops +/// where the user didn't use a C do-while loop. For example, seemingly +/// well-behaved top-test loops will commonly be lowered like this: // /// if (n > 0) { /// i = 0; @@ -2071,14 +2071,14 @@ /// test in such a way that indvars can't find it. /// /// When indvars can't find the if test in loops like this, it creates a -/// max expression, which allows it to give the loop a canonical +/// signed-max expression, which allows it to give the loop a canonical /// induction variable: /// /// i = 0; -/// max = n < 1 ? 1 : n; +/// smax = n < 1 ? 1 : n; /// do { /// p[i] = 0.0; -/// } while (++i != max); +/// } while (++i != smax); /// /// Canonical induction variables are necessary because the loop passes /// are designed around them. The most obvious example of this is the @@ -2094,8 +2094,8 @@ /// rewriting their conditions from ICMP_NE back to ICMP_SLT, and deleting /// the instructions for the maximum computation. /// -ICmpInst *LoopStrengthReduce::OptimizeMax(Loop *L, ICmpInst *Cond, - IVStrideUse* &CondUse) { +ICmpInst *LoopStrengthReduce::OptimizeSMax(Loop *L, ICmpInst *Cond, + IVStrideUse* &CondUse) { // Check that the loop matches the pattern we're looking for. if (Cond->getPredicate() != CmpInst::ICMP_EQ && Cond->getPredicate() != CmpInst::ICMP_NE) @@ -2113,14 +2113,12 @@ SCEVHandle IterationCount = SE->getAddExpr(BackedgeTakenCount, One); // Check for a max calculation that matches the pattern. - if (!isa(IterationCount) && !isa(IterationCount)) - return Cond; - const SCEVNAryExpr *Max = cast(IterationCount); - if (Max != SE->getSCEV(Sel)) return Cond; + const SCEVSMaxExpr *SMax = dyn_cast(IterationCount); + if (!SMax || SMax != SE->getSCEV(Sel)) return Cond; - SCEVHandle MaxLHS = Max->getOperand(0); - SCEVHandle MaxRHS = Max->getOperand(1); - if (!MaxLHS || MaxLHS != One) return Cond; + SCEVHandle SMaxLHS = SMax->getOperand(0); + SCEVHandle SMaxRHS = SMax->getOperand(1); + if (!SMaxLHS || SMaxLHS != One) return Cond; // Check the relevant induction variable for conformance to // the pattern. @@ -2137,23 +2135,19 @@ // Check the right operand of the select, and remember it, as it will // be used in the new comparison instruction. Value *NewRHS = 0; - if (SE->getSCEV(Sel->getOperand(1)) == MaxRHS) + if (SE->getSCEV(Sel->getOperand(1)) == SMaxRHS) NewRHS = Sel->getOperand(1); - else if (SE->getSCEV(Sel->getOperand(2)) == MaxRHS) + else if (SE->getSCEV(Sel->getOperand(2)) == SMaxRHS) NewRHS = Sel->getOperand(2); if (!NewRHS) return Cond; - // Determine the new comparison opcode. It may be signed or unsigned, - // and the original comparison may be either equality or inequality. - CmpInst::Predicate Pred = - isa(Max) ? CmpInst::ICMP_SLT : CmpInst::ICMP_ULT; - if (Cond->getPredicate() == CmpInst::ICMP_EQ) - Pred = CmpInst::getInversePredicate(Pred); - // Ok, everything looks ok to change the condition into an SLT or SGE and // delete the max calculation. ICmpInst *NewCond = - new ICmpInst(Pred, Cond->getOperand(0), NewRHS, "scmp", Cond); + new ICmpInst(Cond->getPredicate() == CmpInst::ICMP_NE ? + CmpInst::ICMP_SLT : + CmpInst::ICMP_SGE, + Cond->getOperand(0), NewRHS, "scmp", Cond); // Delete the max calculation instructions. Cond->replaceAllUsesWith(NewCond); @@ -2366,10 +2360,10 @@ StrideNoReuse.insert(*CondStride); } - // If the trip count is computed in terms of a max (due to ScalarEvolution + // If the trip count is computed in terms of an smax (due to ScalarEvolution // being unable to find a sufficient guard, for example), change the loop - // comparison to use SLT or ULT instead of NE. - Cond = OptimizeMax(L, Cond, CondUse); + // comparison to use SLT instead of NE. + Cond = OptimizeSMax(L, Cond, CondUse); // If possible, change stride and operands of the compare instruction to // eliminate one stride. Modified: llvm/trunk/test/CodeGen/X86/optimize-max-0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/optimize-max-0.ll?rev=73783&r1=73782&r2=73783&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/optimize-max-0.ll (original) +++ llvm/trunk/test/CodeGen/X86/optimize-max-0.ll Fri Jun 19 16:15:06 2009 @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86 | not grep cmov +; XFAIL: * ; LSR should be able to eliminate the max computations by ; making the loops use slt/ult comparisons instead of ne comparisons. Modified: llvm/trunk/test/CodeGen/X86/optimize-max-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/optimize-max-1.ll?rev=73783&r1=73782&r2=73783&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/optimize-max-1.ll (original) +++ llvm/trunk/test/CodeGen/X86/optimize-max-1.ll Fri Jun 19 16:15:06 2009 @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86-64 | not grep cmov +; XFAIL: * ; LSR should be able to eliminate both smax and umax expressions ; in loop trip counts. From dpatel at apple.com Fri Jun 19 16:54:28 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 19 Jun 2009 21:54:28 -0000 Subject: [llvm-commits] [llvm] r73784 - in /llvm/trunk/lib: CodeGen/AsmPrinter/AsmPrinter.cpp Target/ARM/ARMTargetAsmInfo.cpp Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Target/X86/AsmPrinter/X86ATTAsmPrinter.h Target/XCore/XCoreAsmPrinter.cpp Target/XCore/XCoreTargetAsmInfo.cpp Message-ID: <200906192154.n5JLsT75025435@zion.cs.uiuc.edu> Author: dpatel Date: Fri Jun 19 16:54:26 2009 New Revision: 73784 URL: http://llvm.org/viewvc/llvm-project?rev=73784&view=rev Log: Move up dwarf writer initialization in common AsmPrinter class. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=73784&r1=73783&r2=73784&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Jun 19 16:54:26 2009 @@ -177,9 +177,17 @@ SwitchToDataSection(""); // Reset back to no section. - MachineModuleInfo *MMI = getAnalysisIfAvailable(); - if (MMI) MMI->AnalyzeModule(M); - DW = getAnalysisIfAvailable(); + if (TAI->doesSupportDebugInformation() + || TAI->doesSupportExceptionHandling()) { + MachineModuleInfo *MMI = getAnalysisIfAvailable(); + if (MMI) { + MMI->AnalyzeModule(M); + DW = getAnalysisIfAvailable(); + if (DW) + DW->BeginModule(&M, MMI, O, this, TAI); + } + } + return false; } Modified: llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp?rev=73784&r1=73783&r2=73784&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetAsmInfo.cpp Fri Jun 19 16:54:26 2009 @@ -52,6 +52,7 @@ SetDirective = "\t.set\t"; ProtectedDirective = NULL; HasDotTypeDotSizeDirective = false; + SupportsDebugInformation = true; } ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM): @@ -85,6 +86,7 @@ StaticCtorsSection = "\t.section .ctors,\"aw\",%progbits"; StaticDtorsSection = "\t.section .dtors,\"aw\",%progbits"; } + SupportsDebugInformation = true; } /// Count the number of comma-separated arguments. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=73784&r1=73783&r2=73784&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Jun 19 16:54:26 2009 @@ -828,13 +828,7 @@ bool ARMAsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); - - // Emit initial debug information. - MMI = getAnalysisIfAvailable(); - assert(MMI); DW = getAnalysisIfAvailable(); - assert(DW && "Dwarf Writer is not available"); - DW->BeginModule(&M, MMI, O, this, TAI); // Thumb-2 instructions are supported only in unified assembler syntax mode. if (Subtarget->hasThumb2()) Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=73784&r1=73783&r2=73784&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Fri Jun 19 16:54:26 2009 @@ -490,12 +490,8 @@ bool LinuxAsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); - SwitchToTextSection("\t.text"); - // Emit initial debug information. DW = getAnalysisIfAvailable(); - assert(DW && "Dwarf Writer is not available"); - MMI = getAnalysisIfAvailable(); - DW->BeginModule(&M, MMI, O, this, TAI); + SwitchToTextSection("\t.text"); return Result; } Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=73784&r1=73783&r2=73784&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Fri Jun 19 16:54:26 2009 @@ -646,16 +646,8 @@ bool PPCLinuxAsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); - - // Emit initial debug information. - MMI = getAnalysisIfAvailable(); - assert(MMI); DW = getAnalysisIfAvailable(); - assert(DW && "DwarfWriter is not available"); - DW->BeginModule(&M, MMI, O, this, TAI); - SwitchToSection(TAI->getTextSection()); - return Result; } @@ -872,15 +864,7 @@ O << "\t.machine " << CPUDirectives[Directive] << '\n'; bool Result = AsmPrinter::doInitialization(M); - - // Emit initial debug information. - // We need this for Personality functions. - // AsmPrinter::doInitialization should have done this analysis. - MMI = getAnalysisIfAvailable(); - assert(MMI); DW = getAnalysisIfAvailable(); - assert(DW && "DwarfWriter is not available"); - DW->BeginModule(&M, MMI, O, this, TAI); // Prime text sections so they are adjacent. This reduces the likelihood a // large data or debug section causes a branch to exceed 16M limit. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73784&r1=73783&r2=73784&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Fri Jun 19 16:54:26 2009 @@ -780,19 +780,7 @@ /// doInitialization bool X86ATTAsmPrinter::doInitialization(Module &M) { - - bool Result = AsmPrinter::doInitialization(M); - - if (TAI->doesSupportDebugInformation()) { - // Let PassManager know we need debug information and relay - // the MachineModuleInfo address on to DwarfWriter. - // AsmPrinter::doInitialization did this analysis. - MMI = getAnalysisIfAvailable(); - DW = getAnalysisIfAvailable(); - DW->BeginModule(&M, MMI, O, this, TAI); - } - - return Result; + return AsmPrinter::doInitialization(M); } @@ -1046,8 +1034,8 @@ } // Emit final debug information. - DwarfWriter *DW = getAnalysisIfAvailable(); - DW->EndModule(); + if (TAI->doesSupportDebugInformation()) + DW->EndModule(); // Funny Darwin hack: This flag tells the linker that no global symbols // contain code that falls through to other global symbols (e.g. the obvious @@ -1066,12 +1054,12 @@ } // Emit final debug information. - DwarfWriter *DW = getAnalysisIfAvailable(); - DW->EndModule(); + if (TAI->doesSupportDebugInformation()) + DW->EndModule(); } else if (Subtarget->isTargetELF()) { // Emit final debug information. - DwarfWriter *DW = getAnalysisIfAvailable(); - DW->EndModule(); + if (TAI->doesSupportDebugInformation()) + DW->EndModule(); } return AsmPrinter::doFinalization(M); Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h?rev=73784&r1=73783&r2=73784&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Fri Jun 19 16:54:26 2009 @@ -30,14 +30,13 @@ class MCInst; class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter { - DwarfWriter *DW; MachineModuleInfo *MMI; const X86Subtarget *Subtarget; public: explicit X86ATTAsmPrinter(raw_ostream &O, X86TargetMachine &TM, const TargetAsmInfo *T, CodeGenOpt::Level OL, bool V) - : AsmPrinter(O, TM, T, OL, V), DW(0), MMI(0) { + : AsmPrinter(O, TM, T, OL, V), MMI(0) { Subtarget = &TM.getSubtarget(); } Modified: llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp?rev=73784&r1=73783&r2=73784&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp Fri Jun 19 16:54:26 2009 @@ -428,6 +428,7 @@ bool XCoreAsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); + DW = getAnalysisIfAvailable(); if (!FileDirective.empty()) { emitFileDirective(FileDirective); @@ -449,11 +450,6 @@ } } - // Emit initial debug information. - DW = getAnalysisIfAvailable(); - assert(DW && "Dwarf Writer is not available"); - DW->BeginModule(&M, getAnalysisIfAvailable(), - O, this, TAI); return Result; } Modified: llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp?rev=73784&r1=73783&r2=73784&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreTargetAsmInfo.cpp Fri Jun 19 16:54:26 2009 @@ -24,6 +24,7 @@ XCoreTargetAsmInfo::XCoreTargetAsmInfo(const XCoreTargetMachine &TM) : ELFTargetAsmInfo(TM), Subtarget(TM.getSubtargetImpl()) { + SupportsDebugInformation = true; TextSection = getUnnamedSection("\t.text", SectionFlags::Code); DataSection = getNamedSection("\t.dp.data", SectionFlags::Writeable | SectionFlags::Small); From dpatel at apple.com Fri Jun 19 17:08:59 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 19 Jun 2009 22:08:59 -0000 Subject: [llvm-commits] [llvm] r73786 - in /llvm/trunk: include/llvm/CodeGen/DebugLoc.h include/llvm/CodeGen/FastISel.h include/llvm/CodeGen/MachineFunction.h include/llvm/CodeGen/MachineInstr.h include/llvm/CodeGen/SelectionDAGNodes.h include/llvm/Support/DebugLoc.h include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/FastISel.cpp lib/Target/PIC16/PIC16DebugInfo.cpp Message-ID: <200906192208.n5JM8xYe025913@zion.cs.uiuc.edu> Author: dpatel Date: Fri Jun 19 17:08:58 2009 New Revision: 73786 URL: http://llvm.org/viewvc/llvm-project?rev=73786&view=rev Log: mv CodeGen/DebugLoc.h Support/DebugLoc.h Added: llvm/trunk/include/llvm/Support/DebugLoc.h - copied, changed from r73783, llvm/trunk/include/llvm/CodeGen/DebugLoc.h Removed: llvm/trunk/include/llvm/CodeGen/DebugLoc.h Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h llvm/trunk/include/llvm/CodeGen/MachineFunction.h llvm/trunk/include/llvm/CodeGen/MachineInstr.h llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Removed: llvm/trunk/include/llvm/CodeGen/DebugLoc.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DebugLoc.h?rev=73785&view=auto ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DebugLoc.h (original) +++ llvm/trunk/include/llvm/CodeGen/DebugLoc.h (removed) @@ -1,101 +0,0 @@ -//===---- llvm/CodeGen/DebugLoc.h - Debug Location Information --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines a number of light weight data structures used by the code -// generator to describe and track debug location information. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CODEGEN_DEBUGLOC_H -#define LLVM_CODEGEN_DEBUGLOC_H - -#include "llvm/ADT/DenseMap.h" -#include - -namespace llvm { - class GlobalVariable; - - /// DebugLocTuple - Debug location tuple of filename id, line and column. - /// - struct DebugLocTuple { - GlobalVariable *CompileUnit; - unsigned Line, Col; - - DebugLocTuple(GlobalVariable *v, unsigned l, unsigned c) - : CompileUnit(v), Line(l), Col(c) {}; - - bool operator==(const DebugLocTuple &DLT) const { - return CompileUnit == DLT.CompileUnit && - Line == DLT.Line && Col == DLT.Col; - } - bool operator!=(const DebugLocTuple &DLT) const { - return !(*this == DLT); - } - }; - - /// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr - /// to index into a vector of unique debug location tuples. - class DebugLoc { - unsigned Idx; - - public: - DebugLoc() : Idx(~0U) {} // Defaults to invalid. - - static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = ~0U; return L; } - static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; } - - unsigned getIndex() const { return Idx; } - - /// isUnknown - Return true if there is no debug info for the SDNode / - /// MachineInstr. - bool isUnknown() const { return Idx == ~0U; } - - bool operator==(const DebugLoc &DL) const { return Idx == DL.Idx; } - bool operator!=(const DebugLoc &DL) const { return !(*this == DL); } - }; - - // Partially specialize DenseMapInfo for DebugLocTyple. - template<> struct DenseMapInfo { - static inline DebugLocTuple getEmptyKey() { - return DebugLocTuple(0, ~0U, ~0U); - } - static inline DebugLocTuple getTombstoneKey() { - return DebugLocTuple((GlobalVariable*)~1U, ~1U, ~1U); - } - static unsigned getHashValue(const DebugLocTuple &Val) { - return DenseMapInfo::getHashValue(Val.CompileUnit) ^ - DenseMapInfo::getHashValue(Val.Line) ^ - DenseMapInfo::getHashValue(Val.Col); - } - static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) { - return LHS.CompileUnit == RHS.CompileUnit && - LHS.Line == RHS.Line && - LHS.Col == RHS.Col; - } - - static bool isPod() { return true; } - }; - - /// DebugLocTracker - This class tracks debug location information. - /// - struct DebugLocTracker { - /// DebugLocations - A vector of unique DebugLocTuple's. - /// - std::vector DebugLocations; - - /// DebugIdMap - This maps DebugLocTuple's to indices into the - /// DebugLocations vector. - DenseMap DebugIdMap; - - DebugLocTracker() {} - }; - -} // end namespace llvm - -#endif /* LLVM_CODEGEN_DEBUGLOC_H */ Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=73786&r1=73785&r2=73786&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/FastISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/FastISel.h Fri Jun 19 17:08:58 2009 @@ -16,7 +16,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallSet.h" -#include "llvm/CodeGen/DebugLoc.h" #include "llvm/CodeGen/SelectionDAGNodes.h" namespace llvm { Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=73786&r1=73785&r2=73786&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Fri Jun 19 17:08:58 2009 @@ -19,7 +19,7 @@ #define LLVM_CODEGEN_MACHINEFUNCTION_H #include "llvm/ADT/ilist.h" -#include "llvm/CodeGen/DebugLoc.h" +#include "llvm/Support/DebugLoc.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Support/Annotation.h" #include "llvm/Support/Allocator.h" Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=73786&r1=73785&r2=73786&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Fri Jun 19 17:08:58 2009 @@ -22,7 +22,7 @@ #include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/MachineMemOperand.h" #include "llvm/Target/TargetInstrDesc.h" -#include "llvm/CodeGen/DebugLoc.h" +#include "llvm/Support/DebugLoc.h" #include #include Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=73786&r1=73785&r2=73786&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Fri Jun 19 17:08:58 2009 @@ -31,7 +31,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/RecyclingAllocator.h" #include "llvm/Support/DataTypes.h" -#include "llvm/CodeGen/DebugLoc.h" +#include "llvm/Support/DebugLoc.h" #include #include Copied: llvm/trunk/include/llvm/Support/DebugLoc.h (from r73783, llvm/trunk/include/llvm/CodeGen/DebugLoc.h) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?p2=llvm/trunk/include/llvm/Support/DebugLoc.h&p1=llvm/trunk/include/llvm/CodeGen/DebugLoc.h&r1=73783&r2=73786&rev=73786&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DebugLoc.h (original) +++ llvm/trunk/include/llvm/Support/DebugLoc.h Fri Jun 19 17:08:58 2009 @@ -1,4 +1,4 @@ -//===---- llvm/CodeGen/DebugLoc.h - Debug Location Information --*- C++ -*-===// +//===---- llvm/DebugLoc.h - Debug Location Information ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// // -// This file defines a number of light weight data structures used by the code -// generator to describe and track debug location information. +// This file defines a number of light weight data structures used +// to describe and track debug location information. // //===----------------------------------------------------------------------===// -#ifndef LLVM_CODEGEN_DEBUGLOC_H -#define LLVM_CODEGEN_DEBUGLOC_H +#ifndef LLVM_DEBUGLOC_H +#define LLVM_DEBUGLOC_H #include "llvm/ADT/DenseMap.h" #include @@ -98,4 +98,4 @@ } // end namespace llvm -#endif /* LLVM_CODEGEN_DEBUGLOC_H */ +#endif /* LLVM_DEBUGLOC_H */ Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=73786&r1=73785&r2=73786&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri Jun 19 17:08:58 2009 @@ -30,7 +30,7 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/CodeGen/DebugLoc.h" +#include "llvm/Support/DebugLoc.h" #include "llvm/Target/TargetMachine.h" #include #include Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=73786&r1=73785&r2=73786&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri Jun 19 17:08:58 2009 @@ -47,7 +47,6 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" -#include "llvm/CodeGen/DebugLoc.h" #include "llvm/CodeGen/DwarfWriter.h" #include "llvm/Analysis/DebugInfo.h" #include "llvm/Target/TargetData.h" Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=73786&r1=73785&r2=73786&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Fri Jun 19 17:08:58 2009 @@ -15,7 +15,7 @@ #include "PIC16DebugInfo.h" #include "llvm/GlobalVariable.h" #include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/DebugLoc.h" +#include "llvm/Support/DebugLoc.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; From gohman at apple.com Fri Jun 19 18:03:47 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Jun 2009 23:03:47 -0000 Subject: [llvm-commits] [llvm] r73787 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200906192303.n5JN3lOA027645@zion.cs.uiuc.edu> Author: djg Date: Fri Jun 19 18:03:46 2009 New Revision: 73787 URL: http://llvm.org/viewvc/llvm-project?rev=73787&view=rev Log: Fix LSR's OptimizeSMax to ignore max operators with more than 2 operands, which it isn't prepared to handle. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=73787&r1=73786&r2=73787&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Jun 19 18:03:46 2009 @@ -2116,6 +2116,11 @@ const SCEVSMaxExpr *SMax = dyn_cast(IterationCount); if (!SMax || SMax != SE->getSCEV(Sel)) return Cond; + // Two handle a max with more than two operands, this optimization would + // require additional checking and setup. + if (SMax->getNumOperands() != 2) + return Cond; + SCEVHandle SMaxLHS = SMax->getOperand(0); SCEVHandle SMaxRHS = SMax->getOperand(1); if (!SMaxLHS || SMaxLHS != One) return Cond; From dalej at apple.com Fri Jun 19 18:05:24 2009 From: dalej at apple.com (Dale Johannesen) Date: Fri, 19 Jun 2009 23:05:24 -0000 Subject: [llvm-commits] [llvm] r73788 - /llvm/tags/Apple/llvmCore-9999/ Message-ID: <200906192305.n5JN5ORq027697@zion.cs.uiuc.edu> Author: johannes Date: Fri Jun 19 18:05:23 2009 New Revision: 73788 URL: http://llvm.org/viewvc/llvm-project?rev=73788&view=rev Log: Creating llvmCore-9999 branch Added: llvm/tags/Apple/llvmCore-9999/ - copied from r73787, llvm/trunk/ From dalej at apple.com Fri Jun 19 18:10:40 2009 From: dalej at apple.com (Dale Johannesen) Date: Fri, 19 Jun 2009 23:10:40 -0000 Subject: [llvm-commits] [llvm] r73789 - /llvm/tags/Apple/llvmCore-9999/ Message-ID: <200906192310.n5JNAeiB027839@zion.cs.uiuc.edu> Author: johannes Date: Fri Jun 19 18:10:40 2009 New Revision: 73789 URL: http://llvm.org/viewvc/llvm-project?rev=73789&view=rev Log: Remove accidental branch. Removed: llvm/tags/Apple/llvmCore-9999/ From resistor at mac.com Fri Jun 19 18:16:20 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 23:16:20 -0000 Subject: [llvm-commits] [llvm] r73790 - in /llvm/trunk: include/llvm/Constant.h include/llvm/Constants.h include/llvm/GlobalValue.h include/llvm/MDNode.h lib/VMCore/ConstantFold.cpp lib/VMCore/ConstantFold.h lib/VMCore/Constants.cpp lib/VMCore/Globals.cpp Message-ID: <200906192316.n5JNGLLx028062@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 18:16:19 2009 New Revision: 73790 URL: http://llvm.org/viewvc/llvm-project?rev=73790&view=rev Log: Fix a serious bug that would cause deadlock during abstract type refinement. The constant creation gets involved, and we end up trying to recursively acquire a writer lock. The fix for this is slightly horrible, and involves passing a boolean "locked" parameter around in Constants.cpp, but it's better than having locked and unlocked versions of most of the code. Modified: llvm/trunk/include/llvm/Constant.h llvm/trunk/include/llvm/Constants.h llvm/trunk/include/llvm/GlobalValue.h llvm/trunk/include/llvm/MDNode.h llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/lib/VMCore/ConstantFold.h llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Globals.cpp Modified: llvm/trunk/include/llvm/Constant.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constant.h?rev=73790&r1=73789&r2=73790&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constant.h (original) +++ llvm/trunk/include/llvm/Constant.h Fri Jun 19 18:16:19 2009 @@ -61,7 +61,7 @@ public: /// Static constructor to get a '0' constant of arbitrary type... /// - static Constant *getNullValue(const Type *Ty); + static Constant *getNullValue(const Type *Ty, bool locked = true); /// Static constructor to get a '-1' constant. This supports integers and /// vectors. @@ -107,7 +107,9 @@ /// available cached constants. Implementations should call /// destroyConstantImpl as the last thing they do, to destroy all users and /// delete this. - virtual void destroyConstant() { assert(0 && "Not reached!"); } + virtual void destroyConstant(bool locked = true) { + assert(0 && "Not reached!"); + } //// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Constant *) { return true; } Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=73790&r1=73789&r2=73790&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Fri Jun 19 18:16:19 2009 @@ -109,11 +109,13 @@ /// the type. /// @brief Get a ConstantInt for a specific value. static ConstantInt *get(const IntegerType *Ty, - uint64_t V, bool isSigned = false); + uint64_t V, bool isSigned = false, + bool locked = true); /// If Ty is a vector type, return a Constant with a splat of the given /// value. Otherwise return a ConstantInt for the given value. - static Constant *get(const Type *Ty, uint64_t V, bool isSigned = false); + static Constant *get(const Type *Ty, uint64_t V, + bool isSigned = false, bool locked = true); /// Return a ConstantInt with the specified value for the specified type. The /// value V will be canonicalized to a an unsigned APInt. Accessing it with @@ -129,11 +131,11 @@ /// Return a ConstantInt with the specified value and an implied Type. The /// type is the integer type that corresponds to the bit width of the value. - static ConstantInt *get(const APInt &V); + static ConstantInt *get(const APInt &V, bool locked = true); /// If Ty is a vector type, return a Constant with a splat of the given /// value. Otherwise return a ConstantInt for the given value. - static Constant *get(const Type *Ty, const APInt &V); + static Constant *get(const Type *Ty, const APInt &V, bool locked = true); /// getType - Specialize the getType() method to always return an IntegerType, /// which reduces the amount of casting needed in parts of the compiler. @@ -230,7 +232,7 @@ /// @returns the value for an integer constant of the given type that has all /// its bits set to true. /// @brief Get the all ones value - static ConstantInt *getAllOnesValue(const Type *Ty); + static ConstantInt *getAllOnesValue(const Type *Ty, bool locked = true); /// @brief Methods to support type inquiry through isa, cast, and dyn_cast. static inline bool classof(const ConstantInt *) { return true; } @@ -259,13 +261,13 @@ } public: /// get() - Static factory methods - Return objects of the specified value - static ConstantFP *get(const APFloat &V); + static ConstantFP *get(const APFloat &V, bool locked = true); /// get() - This returns a ConstantFP, or a vector containing a splat of a /// ConstantFP, for the specified value in the specified type. This should /// only be used for simple constant values like 2.0/1.0 etc, that are /// known-valid both as host double and as the target format. - static Constant *get(const Type *Ty, double V); + static Constant *get(const Type *Ty, double V, bool locked = true); /// isValueValidForType - return true if Ty is big enough to represent V. static bool isValueValidForType(const Type *Ty, const APFloat& V); @@ -321,13 +323,13 @@ public: /// get() - static factory method for creating a null aggregate. It is /// illegal to call this method with a non-aggregate type. - static ConstantAggregateZero *get(const Type *Ty); + static ConstantAggregateZero *get(const Type *Ty, bool locked = true); /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. virtual bool isNullValue() const { return true; } - virtual void destroyConstant(); + virtual void destroyConstant(bool locked = true); /// Methods for support type inquiry through isa, cast, and dyn_cast: /// @@ -349,9 +351,11 @@ ConstantArray(const ArrayType *T, const std::vector &Val); public: /// get() - Static factory methods - Return objects of the specified value - static Constant *get(const ArrayType *T, const std::vector &); + static Constant *get(const ArrayType *T, const std::vector &, + bool locked = true); static Constant *get(const ArrayType *T, - Constant*const*Vals, unsigned NumVals) { + Constant*const*Vals, unsigned NumVals, + bool locked = true) { // FIXME: make this the primary ctor method. return get(T, std::vector(Vals, Vals+NumVals)); } @@ -362,7 +366,8 @@ /// of the array by one (you've been warned). However, in some situations /// this is not desired so if AddNull==false then the string is copied without /// null termination. - static Constant *get(const std::string &Initializer, bool AddNull = true); + static Constant *get(const std::string &Initializer, + bool AddNull = true, bool locked = true); /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); @@ -395,7 +400,7 @@ /// created as ConstantAggregateZero objects. virtual bool isNullValue() const { return false; } - virtual void destroyConstant(); + virtual void destroyConstant(bool locked = true); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -423,12 +428,14 @@ public: /// get() - Static factory methods - Return objects of the specified value /// - static Constant *get(const StructType *T, const std::vector &V); - static Constant *get(const std::vector &V, bool Packed = false); + static Constant *get(const StructType *T, const std::vector &V, + bool locked = true); + static Constant *get(const std::vector &V, bool Packed = false, + bool locked = true); static Constant *get(Constant*const* Vals, unsigned NumVals, - bool Packed = false) { + bool Packed = false, bool locked = true) { // FIXME: make this the primary ctor method. - return get(std::vector(Vals, Vals+NumVals), Packed); + return get(std::vector(Vals, Vals+NumVals), Packed, locked); } /// Transparently provide more efficient getOperand methods. @@ -447,7 +454,7 @@ return false; } - virtual void destroyConstant(); + virtual void destroyConstant(bool locked = true); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -474,11 +481,13 @@ ConstantVector(const VectorType *T, const std::vector &Val); public: /// get() - Static factory methods - Return objects of the specified value - static Constant *get(const VectorType *T, const std::vector &); - static Constant *get(const std::vector &V); - static Constant *get(Constant*const* Vals, unsigned NumVals) { + static Constant *get(const VectorType *T, const std::vector &, + bool locked = true); + static Constant *get(const std::vector &V, bool locked = true); + static Constant *get(Constant*const* Vals, unsigned NumVals, + bool locked = true) { // FIXME: make this the primary ctor method. - return get(std::vector(Vals, Vals+NumVals)); + return get(std::vector(Vals, Vals+NumVals), locked); } /// Transparently provide more efficient getOperand methods. @@ -494,7 +503,8 @@ /// @returns the value for a vector integer constant of the given type that /// has all its bits set to true. /// @brief Get the all ones value - static ConstantVector *getAllOnesValue(const VectorType *Ty); + static ConstantVector *getAllOnesValue(const VectorType *Ty, + bool locked = true); /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. This always returns false because zero vectors are always @@ -511,7 +521,7 @@ /// elements have the same value, return that value. Otherwise return NULL. Constant *getSplatValue(); - virtual void destroyConstant(); + virtual void destroyConstant(bool locked = true); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -546,13 +556,13 @@ } public: /// get() - Static factory methods - Return objects of the specified value - static ConstantPointerNull *get(const PointerType *T); + static ConstantPointerNull *get(const PointerType *T, bool locked = true); /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. virtual bool isNullValue() const { return true; } - virtual void destroyConstant(); + virtual void destroyConstant(bool locked = true); /// getType - Specialize the getType() method to always return an PointerType, /// which reduces the amount of casting needed in parts of the compiler. @@ -590,13 +600,14 @@ // These private methods are used by the type resolution code to create // ConstantExprs in intermediate forms. static Constant *getTy(const Type *Ty, unsigned Opcode, - Constant *C1, Constant *C2); + Constant *C1, Constant *C2, bool locked = true); static Constant *getCompareTy(unsigned short pred, Constant *C1, Constant *C2); - static Constant *getSelectTy(const Type *Ty, - Constant *C1, Constant *C2, Constant *C3); + static Constant *getSelectTy(const Type *Ty, Constant *C1, Constant *C2, + Constant *C3, bool locked = true); static Constant *getGetElementPtrTy(const Type *Ty, Constant *C, - Value* const *Idxs, unsigned NumIdxs); + Value* const *Idxs, unsigned NumIdxs, + bool locked = true); static Constant *getExtractElementTy(const Type *Ty, Constant *Val, Constant *Idx); static Constant *getInsertElementTy(const Type *Ty, Constant *Val, @@ -617,18 +628,18 @@ /// Cast constant expr /// - static Constant *getTrunc (Constant *C, const Type *Ty); - static Constant *getSExt (Constant *C, const Type *Ty); - static Constant *getZExt (Constant *C, const Type *Ty); - static Constant *getFPTrunc (Constant *C, const Type *Ty); - static Constant *getFPExtend(Constant *C, const Type *Ty); - static Constant *getUIToFP (Constant *C, const Type *Ty); - static Constant *getSIToFP (Constant *C, const Type *Ty); - static Constant *getFPToUI (Constant *C, const Type *Ty); - static Constant *getFPToSI (Constant *C, const Type *Ty); - static Constant *getPtrToInt(Constant *C, const Type *Ty); - static Constant *getIntToPtr(Constant *C, const Type *Ty); - static Constant *getBitCast (Constant *C, const Type *Ty); + static Constant *getTrunc (Constant *C, const Type *Ty, bool locked = true); + static Constant *getSExt (Constant *C, const Type *Ty, bool locked = true); + static Constant *getZExt (Constant *C, const Type *Ty, bool locked = true); + static Constant *getFPTrunc (Constant *C, const Type *Ty, bool locked = true); + static Constant *getFPExtend(Constant *C, const Type *Ty, bool locked = true); + static Constant *getUIToFP (Constant *C, const Type *Ty, bool locked = true); + static Constant *getSIToFP (Constant *C, const Type *Ty, bool locked = true); + static Constant *getFPToUI (Constant *C, const Type *Ty, bool locked = true); + static Constant *getFPToSI (Constant *C, const Type *Ty, bool locked = true); + static Constant *getPtrToInt(Constant *C, const Type *Ty, bool locked = true); + static Constant *getIntToPtr(Constant *C, const Type *Ty, bool locked = true); + static Constant *getBitCast (Constant *C, const Type *Ty, bool locked = true); /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); @@ -638,7 +649,8 @@ static Constant *getCast( unsigned ops, ///< The opcode for the conversion Constant *C, ///< The constant to be converted - const Type *Ty ///< The type to which the constant is converted + const Type *Ty, ///< The type to which the constant is converted + bool locked = true ); // @brief Create a ZExt or BitCast cast constant expression @@ -650,7 +662,8 @@ // @brief Create a SExt or BitCast cast constant expression static Constant *getSExtOrBitCast( Constant *C, ///< The constant to sext or bitcast - const Type *Ty ///< The type to sext or bitcast C to + const Type *Ty, ///< The type to sext or bitcast C to + bool locked = true ); // @brief Create a Trunc or BitCast cast constant expression @@ -662,7 +675,8 @@ /// @brief Create a BitCast or a PtrToInt cast constant expression static Constant *getPointerCast( Constant *C, ///< The pointer value to be casted (operand 0) - const Type *Ty ///< The type to which cast should be made + const Type *Ty, ///< The type to which cast should be made + bool locked = true ); /// @brief Create a ZExt, Bitcast or Trunc for integer -> integer casts @@ -708,7 +722,8 @@ /// ConstantExpr::get - Return a binary or shift operator constant expression, /// folding if possible. /// - static Constant *get(unsigned Opcode, Constant *C1, Constant *C2); + static Constant *get(unsigned Opcode, Constant *C1, Constant *C2, + bool locked = true); /// @brief Return an ICmp, FCmp, VICmp, or VFCmp comparison operator constant /// expression. @@ -720,36 +735,38 @@ static Constant *getNeg(Constant *C); static Constant *getFNeg(Constant *C); static Constant *getNot(Constant *C); - static Constant *getAdd(Constant *C1, Constant *C2); - static Constant *getFAdd(Constant *C1, Constant *C2); - static Constant *getSub(Constant *C1, Constant *C2); - static Constant *getFSub(Constant *C1, Constant *C2); - static Constant *getMul(Constant *C1, Constant *C2); - static Constant *getFMul(Constant *C1, Constant *C2); - static Constant *getUDiv(Constant *C1, Constant *C2); - static Constant *getSDiv(Constant *C1, Constant *C2); - static Constant *getFDiv(Constant *C1, Constant *C2); - static Constant *getURem(Constant *C1, Constant *C2); // unsigned rem - static Constant *getSRem(Constant *C1, Constant *C2); // signed rem - static Constant *getFRem(Constant *C1, Constant *C2); - static Constant *getAnd(Constant *C1, Constant *C2); - static Constant *getOr(Constant *C1, Constant *C2); - static Constant *getXor(Constant *C1, Constant *C2); + static Constant *getAdd(Constant *C1, Constant *C2, bool locked = true); + static Constant *getFAdd(Constant *C1, Constant *C2, bool locked = true); + static Constant *getSub(Constant *C1, Constant *C2, bool locked = true); + static Constant *getFSub(Constant *C1, Constant *C2, bool locked = true); + static Constant *getMul(Constant *C1, Constant *C2, bool locked = true); + static Constant *getFMul(Constant *C1, Constant *C2, bool locked = true); + static Constant *getUDiv(Constant *C1, Constant *C2, bool locked = true); + static Constant *getSDiv(Constant *C1, Constant *C2, bool locked = true); + static Constant *getFDiv(Constant *C1, Constant *C2, bool locked = true); + // unsigned rem + static Constant *getURem(Constant *C1, Constant *C2, bool locked = true); + // signed rem + static Constant *getSRem(Constant *C1, Constant *C2, bool locked = true); + static Constant *getFRem(Constant *C1, Constant *C2, bool locked = true); + static Constant *getAnd(Constant *C1, Constant *C2, bool locked = true); + static Constant *getOr(Constant *C1, Constant *C2, bool locked = true); + static Constant *getXor(Constant *C1, Constant *C2, bool locked = true); static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getVICmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getVFCmp(unsigned short pred, Constant *LHS, Constant *RHS); - static Constant *getShl(Constant *C1, Constant *C2); - static Constant *getLShr(Constant *C1, Constant *C2); - static Constant *getAShr(Constant *C1, Constant *C2); + static Constant *getShl(Constant *C1, Constant *C2, bool locked = true); + static Constant *getLShr(Constant *C1, Constant *C2, bool locked = true); + static Constant *getAShr(Constant *C1, Constant *C2, bool locked = true); /// Getelementptr form. std::vector is only accepted for convenience: /// all elements must be Constant's. /// - static Constant *getGetElementPtr(Constant *C, - Constant* const *IdxList, unsigned NumIdx); - static Constant *getGetElementPtr(Constant *C, - Value* const *IdxList, unsigned NumIdx); + static Constant *getGetElementPtr(Constant *C, Constant* const *IdxList, + unsigned NumIdx, bool locked = true); + static Constant *getGetElementPtr(Constant *C, Value* const *IdxList, + unsigned NumIdx, bool locked = true); static Constant *getExtractElement(Constant *Vec, Constant *Idx); static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx); @@ -794,7 +811,7 @@ } Constant *getWithOperands(Constant* const *Ops, unsigned NumOps) const; - virtual void destroyConstant(); + virtual void destroyConstant(bool locked = true); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -831,13 +848,13 @@ /// get() - Static factory methods - Return an 'undef' object of the specified /// type. /// - static UndefValue *get(const Type *T); + static UndefValue *get(const Type *T, bool locked = true); /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. virtual bool isNullValue() const { return false; } - virtual void destroyConstant(); + virtual void destroyConstant(bool locked = true); /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const UndefValue *) { return true; } @@ -864,7 +881,8 @@ public: /// get() - Static factory methods - Return objects of the specified value. /// - static MDString *get(const char *StrBegin, const char *StrEnd); + static MDString *get(const char *StrBegin, const char *StrEnd, + bool locked = true); /// size() - The length of this string. /// @@ -891,7 +909,7 @@ return false; } - virtual void destroyConstant(); + virtual void destroyConstant(bool locked = true); /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const MDString *) { return true; } Modified: llvm/trunk/include/llvm/GlobalValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalValue.h?rev=73790&r1=73789&r2=73790&view=diff ============================================================================== --- llvm/trunk/include/llvm/GlobalValue.h (original) +++ llvm/trunk/include/llvm/GlobalValue.h Fri Jun 19 18:16:19 2009 @@ -172,7 +172,7 @@ virtual bool isNullValue() const { return false; } /// Override from Constant class. - virtual void destroyConstant(); + virtual void destroyConstant(bool locked = true); /// isDeclaration - Return true if the primary definition of this global /// value is outside of the current translation unit... Modified: llvm/trunk/include/llvm/MDNode.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MDNode.h?rev=73790&r1=73789&r2=73790&view=diff ============================================================================== --- llvm/trunk/include/llvm/MDNode.h (original) +++ llvm/trunk/include/llvm/MDNode.h Fri Jun 19 18:16:19 2009 @@ -78,7 +78,7 @@ /// get() - Static factory methods - Return objects of the specified value. /// - static MDNode *get(Value*const* Vals, unsigned NumVals); + static MDNode *get(Value*const* Vals, unsigned NumVals, bool locked = true); Value *getElement(unsigned i) const { return Node[i]; @@ -117,7 +117,7 @@ /// duplicates void Profile(FoldingSetNodeID &ID) const; - virtual void destroyConstant(); + virtual void destroyConstant(bool locked = true); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) { assert(0 && "This should never be called because MDNodes have no ops"); abort(); Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=73790&r1=73789&r2=73790&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Fri Jun 19 18:16:19 2009 @@ -40,7 +40,8 @@ /// specified vector type. At this point, we know that the elements of the /// input vector constant are all simple integer or FP values. static Constant *BitCastConstantVector(ConstantVector *CV, - const VectorType *DstTy) { + const VectorType *DstTy, + bool locked) { // If this cast changes element count then we can't handle it here: // doing so requires endianness information. This should be handled by // Analysis/ConstantFolding.cpp @@ -60,7 +61,7 @@ const Type *DstEltTy = DstTy->getElementType(); for (unsigned i = 0; i != NumElts; ++i) Result.push_back(ConstantExpr::getBitCast(CV->getOperand(i), DstEltTy)); - return ConstantVector::get(Result); + return ConstantVector::get(Result, locked); } /// This function determines which opcode to use to fold two constant cast @@ -88,7 +89,8 @@ Type::Int64Ty); } -static Constant *FoldBitCast(Constant *V, const Type *DestTy) { +static Constant *FoldBitCast(Constant *V, const Type *DestTy, + bool locked = true) { const Type *SrcTy = V->getType(); if (SrcTy == DestTy) return V; // no-op cast @@ -99,7 +101,7 @@ if (const PointerType *DPTy = dyn_cast(DestTy)) if (PTy->getAddressSpace() == DPTy->getAddressSpace()) { SmallVector IdxList; - IdxList.push_back(Constant::getNullValue(Type::Int32Ty)); + IdxList.push_back(Constant::getNullValue(Type::Int32Ty, locked)); const Type *ElTy = PTy->getElementType(); while (ElTy != DPTy->getElementType()) { if (const StructType *STy = dyn_cast(ElTy)) { @@ -117,7 +119,8 @@ } if (ElTy == DPTy->getElementType()) - return ConstantExpr::getGetElementPtr(V, &IdxList[0], IdxList.size()); + return ConstantExpr::getGetElementPtr(V, &IdxList[0], + IdxList.size(), locked); } // Handle casts from one vector constant to another. We know that the src @@ -129,23 +132,24 @@ SrcTy = NULL; // First, check for null. Undef is already handled. if (isa(V)) - return Constant::getNullValue(DestTy); + return Constant::getNullValue(DestTy, locked); if (ConstantVector *CV = dyn_cast(V)) - return BitCastConstantVector(CV, DestPTy); + return BitCastConstantVector(CV, DestPTy, locked); } // Canonicalize scalar-to-vector bitcasts into vector-to-vector bitcasts // This allows for other simplifications (although some of them // can only be handled by Analysis/ConstantFolding.cpp). if (isa(V) || isa(V)) - return ConstantExpr::getBitCast(ConstantVector::get(&V, 1), DestPTy); + return ConstantExpr::getBitCast(ConstantVector::get(&V, 1, locked), + DestPTy, locked); } // Finally, implement bitcast folding now. The code below doesn't handle // bitcast right. if (isa(V)) // ptr->ptr cast. - return ConstantPointerNull::get(cast(DestTy)); + return ConstantPointerNull::get(cast(DestTy), locked); // Handle integral constant input. if (const ConstantInt *CI = dyn_cast(V)) { @@ -156,7 +160,7 @@ if (DestTy->isFloatingPoint()) return ConstantFP::get(APFloat(CI->getValue(), - DestTy != Type::PPC_FP128Ty)); + DestTy != Type::PPC_FP128Ty), locked); // Otherwise, can't fold this (vector?) return 0; @@ -165,22 +169,22 @@ // Handle ConstantFP input. if (const ConstantFP *FP = dyn_cast(V)) // FP -> Integral. - return ConstantInt::get(FP->getValueAPF().bitcastToAPInt()); + return ConstantInt::get(FP->getValueAPF().bitcastToAPInt(), locked); return 0; } Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V, - const Type *DestTy) { + const Type *DestTy, bool locked) { if (isa(V)) { // zext(undef) = 0, because the top bits will be zero. // sext(undef) = 0, because the top bits will all be the same. // [us]itofp(undef) = 0, because the result value is bounded. if (opc == Instruction::ZExt || opc == Instruction::SExt || opc == Instruction::UIToFP || opc == Instruction::SIToFP) - return Constant::getNullValue(DestTy); - return UndefValue::get(DestTy); + return Constant::getNullValue(DestTy, locked); + return UndefValue::get(DestTy, locked); } // No compile-time operations on this type yet. if (V->getType() == Type::PPC_FP128Ty || DestTy == Type::PPC_FP128Ty) @@ -192,7 +196,7 @@ if (CE->isCast()) { // Try hard to fold cast of cast because they are often eliminable. if (unsigned newOpc = foldConstantCastPair(opc, CE, DestTy)) - return ConstantExpr::getCast(newOpc, CE->getOperand(0), DestTy); + return ConstantExpr::getCast(newOpc, CE->getOperand(0), DestTy, locked); } else if (CE->getOpcode() == Instruction::GetElementPtr) { // If all of the indexes in the GEP are null values, there is no pointer // adjustment going on. We might as well cast the source pointer. @@ -204,7 +208,7 @@ } if (isAllNull) // This is casting one pointer type to another, always BitCast - return ConstantExpr::getPointerCast(CE->getOperand(0), DestTy); + return ConstantExpr::getPointerCast(CE->getOperand(0), DestTy, locked); } } @@ -220,8 +224,8 @@ const Type *DstEltTy = DestVecTy->getElementType(); for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) res.push_back(ConstantExpr::getCast(opc, - CV->getOperand(i), DstEltTy)); - return ConstantVector::get(DestVecTy, res); + CV->getOperand(i), DstEltTy, locked)); + return ConstantVector::get(DestVecTy, res, locked); } // We actually have to do a cast now. Perform the cast according to the @@ -238,7 +242,7 @@ DestTy == Type::FP128Ty ? APFloat::IEEEquad : APFloat::Bogus, APFloat::rmNearestTiesToEven, &ignored); - return ConstantFP::get(Val); + return ConstantFP::get(Val, locked); } return 0; // Can't fold. case Instruction::FPToUI: @@ -251,16 +255,16 @@ (void) V.convertToInteger(x, DestBitWidth, opc==Instruction::FPToSI, APFloat::rmTowardZero, &ignored); APInt Val(DestBitWidth, 2, x); - return ConstantInt::get(Val); + return ConstantInt::get(Val, locked); } return 0; // Can't fold. case Instruction::IntToPtr: //always treated as unsigned if (V->isNullValue()) // Is it an integral null value? - return ConstantPointerNull::get(cast(DestTy)); + return ConstantPointerNull::get(cast(DestTy), locked); return 0; // Other pointer types cannot be casted case Instruction::PtrToInt: // always treated as unsigned if (V->isNullValue()) // is it a null pointer value? - return ConstantInt::get(DestTy, 0); + return ConstantInt::get(DestTy, 0, locked); return 0; // Other pointer types cannot be casted case Instruction::UIToFP: case Instruction::SIToFP: @@ -272,7 +276,7 @@ (void)apf.convertFromAPInt(api, opc==Instruction::SIToFP, APFloat::rmNearestTiesToEven); - return ConstantFP::get(apf); + return ConstantFP::get(apf, locked); } return 0; case Instruction::ZExt: @@ -280,7 +284,7 @@ uint32_t BitWidth = cast(DestTy)->getBitWidth(); APInt Result(CI->getValue()); Result.zext(BitWidth); - return ConstantInt::get(Result); + return ConstantInt::get(Result, locked); } return 0; case Instruction::SExt: @@ -288,7 +292,7 @@ uint32_t BitWidth = cast(DestTy)->getBitWidth(); APInt Result(CI->getValue()); Result.sext(BitWidth); - return ConstantInt::get(Result); + return ConstantInt::get(Result, locked); } return 0; case Instruction::Trunc: @@ -296,11 +300,11 @@ uint32_t BitWidth = cast(DestTy)->getBitWidth(); APInt Result(CI->getValue()); Result.trunc(BitWidth); - return ConstantInt::get(Result); + return ConstantInt::get(Result, locked); } return 0; case Instruction::BitCast: - return FoldBitCast(const_cast(V), DestTy); + return FoldBitCast(const_cast(V), DestTy, locked); default: assert(!"Invalid CE CastInst opcode"); break; @@ -312,7 +316,7 @@ Constant *llvm::ConstantFoldSelectInstruction(const Constant *Cond, const Constant *V1, - const Constant *V2) { + const Constant *V2, bool locked) { if (const ConstantInt *CB = dyn_cast(Cond)) return const_cast(CB->getZExtValue() ? V1 : V2); @@ -566,21 +570,22 @@ static Constant *EvalVectorOp(const ConstantVector *V1, const ConstantVector *V2, const VectorType *VTy, - Constant *(*FP)(Constant*, Constant*)) { + Constant *(*FP)(Constant*, Constant*, bool)) { std::vector Res; const Type *EltTy = VTy->getElementType(); for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { const Constant *C1 = V1 ? V1->getOperand(i) : Constant::getNullValue(EltTy); const Constant *C2 = V2 ? V2->getOperand(i) : Constant::getNullValue(EltTy); Res.push_back(FP(const_cast(C1), - const_cast(C2))); + const_cast(C2), true)); } return ConstantVector::get(Res); } Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *C1, - const Constant *C2) { + const Constant *C2, + bool locked) { // No compile-time operations on this type yet. if (C1->getType() == Type::PPC_FP128Ty) return 0; @@ -592,29 +597,29 @@ if (isa(C1) && isa(C2)) // Handle undef ^ undef -> 0 special case. This is a common // idiom (misuse). - return Constant::getNullValue(C1->getType()); + return Constant::getNullValue(C1->getType(), locked); // Fallthrough case Instruction::Add: case Instruction::Sub: - return UndefValue::get(C1->getType()); + return UndefValue::get(C1->getType(), locked); case Instruction::Mul: case Instruction::And: - return Constant::getNullValue(C1->getType()); + return Constant::getNullValue(C1->getType(), locked); case Instruction::UDiv: case Instruction::SDiv: case Instruction::URem: case Instruction::SRem: if (!isa(C2)) // undef / X -> 0 - return Constant::getNullValue(C1->getType()); + return Constant::getNullValue(C1->getType(), locked); return const_cast(C2); // X / undef -> undef case Instruction::Or: // X | undef -> -1 if (const VectorType *PTy = dyn_cast(C1->getType())) - return ConstantVector::getAllOnesValue(PTy); - return ConstantInt::getAllOnesValue(C1->getType()); + return ConstantVector::getAllOnesValue(PTy, locked); + return ConstantInt::getAllOnesValue(C1->getType(), locked); case Instruction::LShr: if (isa(C2) && isa(C1)) return const_cast(C1); // undef lshr undef -> undef - return Constant::getNullValue(C1->getType()); // X lshr undef -> 0 + return Constant::getNullValue(C1->getType(), locked); // X lshr undef -> 0 // undef lshr X -> 0 case Instruction::AShr: if (!isa(C2)) @@ -625,7 +630,7 @@ return const_cast(C1); // X ashr undef --> X case Instruction::Shl: // undef << X -> 0 or X << undef -> 0 - return Constant::getNullValue(C1->getType()); + return Constant::getNullValue(C1->getType(), locked); } } @@ -1572,7 +1577,7 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, Constant* const *Idxs, - unsigned NumIdx) { + unsigned NumIdx, bool locked) { if (NumIdx == 0 || (NumIdx == 1 && Idxs[0]->isNullValue())) return const_cast(C); @@ -1583,7 +1588,8 @@ (Value **)Idxs, (Value **)Idxs+NumIdx); assert(Ty != 0 && "Invalid indices for GEP!"); - return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace())); + return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace()), + locked); } Constant *Idx0 = Idxs[0]; @@ -1601,7 +1607,8 @@ (Value**)Idxs+NumIdx); assert(Ty != 0 && "Invalid indices for GEP!"); return - ConstantPointerNull::get(PointerType::get(Ty,Ptr->getAddressSpace())); + ConstantPointerNull::get(PointerType::get(Ty,Ptr->getAddressSpace()), + locked); } } @@ -1629,20 +1636,22 @@ if (!Idx0->isNullValue()) { const Type *IdxTy = Combined->getType(); if (IdxTy != Idx0->getType()) { - Constant *C1 = ConstantExpr::getSExtOrBitCast(Idx0, Type::Int64Ty); + Constant *C1 = ConstantExpr::getSExtOrBitCast(Idx0, Type::Int64Ty, + locked); Constant *C2 = ConstantExpr::getSExtOrBitCast(Combined, - Type::Int64Ty); - Combined = ConstantExpr::get(Instruction::Add, C1, C2); + Type::Int64Ty, + locked); + Combined = ConstantExpr::get(Instruction::Add, C1, C2, locked); } else { Combined = - ConstantExpr::get(Instruction::Add, Idx0, Combined); + ConstantExpr::get(Instruction::Add, Idx0, Combined, locked); } } NewIndices.push_back(Combined); NewIndices.insert(NewIndices.end(), Idxs+1, Idxs+NumIdx); return ConstantExpr::getGetElementPtr(CE->getOperand(0), &NewIndices[0], - NewIndices.size()); + NewIndices.size(), locked); } } @@ -1659,7 +1668,7 @@ dyn_cast(cast(C->getType())->getElementType())) if (CAT->getElementType() == SAT->getElementType()) return ConstantExpr::getGetElementPtr( - (Constant*)CE->getOperand(0), Idxs, NumIdx); + (Constant*)CE->getOperand(0), Idxs, NumIdx, locked); } // Fold: getelementptr (i8* inttoptr (i64 1 to i8*), i32 -1) @@ -1677,10 +1686,10 @@ Offset = ConstantExpr::getSExt(Offset, Base->getType()); else if (Base->getType()->getPrimitiveSizeInBits() < Offset->getType()->getPrimitiveSizeInBits()) - Base = ConstantExpr::getZExt(Base, Offset->getType()); + Base = ConstantExpr::getZExt(Base, Offset->getType(), locked); - Base = ConstantExpr::getAdd(Base, Offset); - return ConstantExpr::getIntToPtr(Base, CE->getType()); + Base = ConstantExpr::getAdd(Base, Offset, locked); + return ConstantExpr::getIntToPtr(Base, CE->getType(), locked); } } return 0; Modified: llvm/trunk/lib/VMCore/ConstantFold.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.h?rev=73790&r1=73789&r2=73790&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.h (original) +++ llvm/trunk/lib/VMCore/ConstantFold.h Fri Jun 19 18:16:19 2009 @@ -28,11 +28,13 @@ Constant *ConstantFoldCastInstruction( unsigned opcode, ///< The opcode of the cast const Constant *V, ///< The source constant - const Type *DestTy ///< The destination type + const Type *DestTy, ///< The destination type + bool locked = true ); Constant *ConstantFoldSelectInstruction(const Constant *Cond, const Constant *V1, - const Constant *V2); + const Constant *V2, + bool locked = true); Constant *ConstantFoldExtractElementInstruction(const Constant *Val, const Constant *Idx); Constant *ConstantFoldInsertElementInstruction(const Constant *Val, @@ -49,12 +51,13 @@ const unsigned* Idxs, unsigned NumIdx); Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1, - const Constant *V2); + const Constant *V2, + bool locked = true); Constant *ConstantFoldCompareInstruction(unsigned short predicate, const Constant *C1, const Constant *C2); - Constant *ConstantFoldGetElementPtr(const Constant *C, - Constant* const *Idxs, unsigned NumIdx); + Constant *ConstantFoldGetElementPtr(const Constant *C, Constant* const *Idxs, + unsigned NumIdx, bool locked = true); } // End llvm namespace #endif Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73790&r1=73789&r2=73790&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Fri Jun 19 18:16:19 2009 @@ -127,27 +127,27 @@ } // Static constructor to create a '0' constant of arbitrary type... -Constant *Constant::getNullValue(const Type *Ty) { +Constant *Constant::getNullValue(const Type *Ty, bool locked) { static uint64_t zero[2] = {0, 0}; switch (Ty->getTypeID()) { case Type::IntegerTyID: - return ConstantInt::get(Ty, 0); + return ConstantInt::get(Ty, 0, locked); case Type::FloatTyID: - return ConstantFP::get(APFloat(APInt(32, 0))); + return ConstantFP::get(APFloat(APInt(32, 0)), locked); case Type::DoubleTyID: - return ConstantFP::get(APFloat(APInt(64, 0))); + return ConstantFP::get(APFloat(APInt(64, 0)), locked); case Type::X86_FP80TyID: - return ConstantFP::get(APFloat(APInt(80, 2, zero))); + return ConstantFP::get(APFloat(APInt(80, 2, zero)), locked); case Type::FP128TyID: - return ConstantFP::get(APFloat(APInt(128, 2, zero), true)); + return ConstantFP::get(APFloat(APInt(128, 2, zero), true), locked); case Type::PPC_FP128TyID: - return ConstantFP::get(APFloat(APInt(128, 2, zero))); + return ConstantFP::get(APFloat(APInt(128, 2, zero)), locked); case Type::PointerTyID: - return ConstantPointerNull::get(cast(Ty)); + return ConstantPointerNull::get(cast(Ty), locked); case Type::StructTyID: case Type::ArrayTyID: case Type::VectorTyID: - return ConstantAggregateZero::get(Ty); + return ConstantAggregateZero::get(Ty, locked); default: // Function, Label, or Opaque type? assert(!"Cannot create a null constant of that type!"); @@ -162,21 +162,22 @@ } // Static constructor to create an integral constant with all bits set -ConstantInt *ConstantInt::getAllOnesValue(const Type *Ty) { +ConstantInt *ConstantInt::getAllOnesValue(const Type *Ty, bool locked) { if (const IntegerType* ITy = dyn_cast(Ty)) - return ConstantInt::get(APInt::getAllOnesValue(ITy->getBitWidth())); + return ConstantInt::get(APInt::getAllOnesValue(ITy->getBitWidth()), locked); return 0; } /// @returns the value for a vector integer constant of the given type that /// has all its bits set to true. /// @brief Get the all ones value -ConstantVector *ConstantVector::getAllOnesValue(const VectorType *Ty) { +ConstantVector *ConstantVector::getAllOnesValue(const VectorType *Ty, + bool locked) { std::vector Elts; Elts.resize(Ty->getNumElements(), - ConstantInt::getAllOnesValue(Ty->getElementType())); + ConstantInt::getAllOnesValue(Ty->getElementType(), locked)); assert(Elts[0] && "Not a vector integer type!"); - return cast(ConstantVector::get(Elts)); + return cast(ConstantVector::get(Elts, locked)); } @@ -275,17 +276,19 @@ static ManagedStatic IntConstants; ConstantInt *ConstantInt::get(const IntegerType *Ty, - uint64_t V, bool isSigned) { - return get(APInt(Ty->getBitWidth(), V, isSigned)); + uint64_t V, bool isSigned, bool locked) { + return get(APInt(Ty->getBitWidth(), V, isSigned), locked); } -Constant *ConstantInt::get(const Type *Ty, uint64_t V, bool isSigned) { +Constant *ConstantInt::get(const Type *Ty, uint64_t V, + bool isSigned, bool locked) { Constant *C = get(cast(Ty->getScalarType()), V, isSigned); // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast(Ty)) return - ConstantVector::get(std::vector(VTy->getNumElements(), C)); + ConstantVector::get(std::vector(VTy->getNumElements(), C), + locked); return C; } @@ -295,38 +298,42 @@ // operator== and operator!= to ensure that the DenseMap doesn't attempt to // compare APInt's of different widths, which would violate an APInt class // invariant which generates an assertion. -ConstantInt *ConstantInt::get(const APInt& V) { +ConstantInt *ConstantInt::get(const APInt& V, bool locked) { // Get the corresponding integer type for the bit width of the value. const IntegerType *ITy = IntegerType::get(V.getBitWidth()); // get an existing value or the insertion position DenseMapAPIntKeyInfo::KeyTy Key(V, ITy); - ConstantsLock->reader_acquire(); + if (locked) ConstantsLock->reader_acquire(); ConstantInt *&Slot = (*IntConstants)[Key]; - ConstantsLock->reader_release(); + if (locked) ConstantsLock->reader_release(); if (!Slot) { - sys::SmartScopedWriter Writer(&*ConstantsLock); - ConstantInt *&NewSlot = (*IntConstants)[Key]; - if (!Slot) { - NewSlot = new ConstantInt(ITy, V); + if (locked) { + sys::SmartScopedWriter Writer(&*ConstantsLock); + ConstantInt *&NewSlot = (*IntConstants)[Key]; + if (!Slot) { + NewSlot = new ConstantInt(ITy, V); + } + return NewSlot; + } else { + Slot = new ConstantInt(ITy, V); } - - return NewSlot; - } else { - return Slot; } + + return Slot; } -Constant *ConstantInt::get(const Type *Ty, const APInt &V) { - ConstantInt *C = ConstantInt::get(V); +Constant *ConstantInt::get(const Type *Ty, const APInt &V, bool locked) { + ConstantInt *C = ConstantInt::get(V, locked); assert(C->getType() == Ty->getScalarType() && "ConstantInt type doesn't match the type implied by its value!"); // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast(Ty)) return - ConstantVector::get(std::vector(VTy->getNumElements(), C)); + ConstantVector::get(std::vector(VTy->getNumElements(), C), + locked); return C; } @@ -405,17 +412,37 @@ static ManagedStatic FPConstants; -ConstantFP *ConstantFP::get(const APFloat &V) { +ConstantFP *ConstantFP::get(const APFloat &V, bool locked) { DenseMapAPFloatKeyInfo::KeyTy Key(V); - ConstantsLock->reader_acquire(); + if (locked) ConstantsLock->reader_acquire(); ConstantFP *&Slot = (*FPConstants)[Key]; - ConstantsLock->reader_release(); + if (locked) ConstantsLock->reader_release(); if (!Slot) { - sys::SmartScopedWriter Writer(&*ConstantsLock); - ConstantFP *&NewSlot = (*FPConstants)[Key]; - if (!NewSlot) { + if (locked) { + sys::SmartScopedWriter Writer(&*ConstantsLock); + ConstantFP *&NewSlot = (*FPConstants)[Key]; + if (!NewSlot) { + const Type *Ty; + if (&V.getSemantics() == &APFloat::IEEEsingle) + Ty = Type::FloatTy; + else if (&V.getSemantics() == &APFloat::IEEEdouble) + Ty = Type::DoubleTy; + else if (&V.getSemantics() == &APFloat::x87DoubleExtended) + Ty = Type::X86_FP80Ty; + else if (&V.getSemantics() == &APFloat::IEEEquad) + Ty = Type::FP128Ty; + else { + assert(&V.getSemantics() == &APFloat::PPCDoubleDouble && + "Unknown FP format"); + Ty = Type::PPC_FP128Ty; + } + NewSlot = new ConstantFP(Ty, V); + } + + return NewSlot; + } else { const Type *Ty; if (&V.getSemantics() == &APFloat::IEEEsingle) Ty = Type::FloatTy; @@ -430,10 +457,8 @@ "Unknown FP format"); Ty = Type::PPC_FP128Ty; } - NewSlot = new ConstantFP(Ty, V); + Slot = new ConstantFP(Ty, V); } - - return NewSlot; } return Slot; @@ -442,17 +467,18 @@ /// get() - This returns a constant fp for the specified value in the /// specified type. This should only be used for simple constant values like /// 2.0/1.0 etc, that are known-valid both as double and as the target format. -Constant *ConstantFP::get(const Type *Ty, double V) { +Constant *ConstantFP::get(const Type *Ty, double V, bool locked) { APFloat FV(V); bool ignored; FV.convert(*TypeToFloatSemantics(Ty->getScalarType()), APFloat::rmNearestTiesToEven, &ignored); - Constant *C = get(FV); + Constant *C = get(FV, locked); // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast(Ty)) return - ConstantVector::get(std::vector(VTy->getNumElements(), C)); + ConstantVector::get(std::vector(VTy->getNumElements(), C), + locked); return C; } @@ -856,50 +882,50 @@ return get(Instruction::Xor, C, Constant::getAllOnesValue(C->getType())); } -Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2) { - return get(Instruction::Add, C1, C2); +Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::Add, C1, C2, locked); } -Constant *ConstantExpr::getFAdd(Constant *C1, Constant *C2) { - return get(Instruction::FAdd, C1, C2); +Constant *ConstantExpr::getFAdd(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::FAdd, C1, C2, locked); } -Constant *ConstantExpr::getSub(Constant *C1, Constant *C2) { - return get(Instruction::Sub, C1, C2); +Constant *ConstantExpr::getSub(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::Sub, C1, C2, locked); } -Constant *ConstantExpr::getFSub(Constant *C1, Constant *C2) { - return get(Instruction::FSub, C1, C2); +Constant *ConstantExpr::getFSub(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::FSub, C1, C2, locked); } -Constant *ConstantExpr::getMul(Constant *C1, Constant *C2) { - return get(Instruction::Mul, C1, C2); +Constant *ConstantExpr::getMul(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::Mul, C1, C2, locked); } -Constant *ConstantExpr::getFMul(Constant *C1, Constant *C2) { - return get(Instruction::FMul, C1, C2); +Constant *ConstantExpr::getFMul(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::FMul, C1, C2, locked); } -Constant *ConstantExpr::getUDiv(Constant *C1, Constant *C2) { - return get(Instruction::UDiv, C1, C2); +Constant *ConstantExpr::getUDiv(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::UDiv, C1, C2, locked); } -Constant *ConstantExpr::getSDiv(Constant *C1, Constant *C2) { - return get(Instruction::SDiv, C1, C2); +Constant *ConstantExpr::getSDiv(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::SDiv, C1, C2, locked); } -Constant *ConstantExpr::getFDiv(Constant *C1, Constant *C2) { - return get(Instruction::FDiv, C1, C2); +Constant *ConstantExpr::getFDiv(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::FDiv, C1, C2, locked); } -Constant *ConstantExpr::getURem(Constant *C1, Constant *C2) { - return get(Instruction::URem, C1, C2); +Constant *ConstantExpr::getURem(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::URem, C1, C2, locked); } -Constant *ConstantExpr::getSRem(Constant *C1, Constant *C2) { - return get(Instruction::SRem, C1, C2); +Constant *ConstantExpr::getSRem(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::SRem, C1, C2, locked); } -Constant *ConstantExpr::getFRem(Constant *C1, Constant *C2) { - return get(Instruction::FRem, C1, C2); +Constant *ConstantExpr::getFRem(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::FRem, C1, C2, locked); } -Constant *ConstantExpr::getAnd(Constant *C1, Constant *C2) { - return get(Instruction::And, C1, C2); +Constant *ConstantExpr::getAnd(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::And, C1, C2, locked); } -Constant *ConstantExpr::getOr(Constant *C1, Constant *C2) { - return get(Instruction::Or, C1, C2); +Constant *ConstantExpr::getOr(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::Or, C1, C2, locked); } -Constant *ConstantExpr::getXor(Constant *C1, Constant *C2) { - return get(Instruction::Xor, C1, C2); +Constant *ConstantExpr::getXor(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::Xor, C1, C2, locked); } unsigned ConstantExpr::getPredicate() const { assert(getOpcode() == Instruction::FCmp || @@ -908,14 +934,14 @@ getOpcode() == Instruction::VICmp); return ((const CompareConstantExpr*)this)->predicate; } -Constant *ConstantExpr::getShl(Constant *C1, Constant *C2) { - return get(Instruction::Shl, C1, C2); +Constant *ConstantExpr::getShl(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::Shl, C1, C2, locked); } -Constant *ConstantExpr::getLShr(Constant *C1, Constant *C2) { - return get(Instruction::LShr, C1, C2); +Constant *ConstantExpr::getLShr(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::LShr, C1, C2, locked); } -Constant *ConstantExpr::getAShr(Constant *C1, Constant *C2) { - return get(Instruction::AShr, C1, C2); +Constant *ConstantExpr::getAShr(Constant *C1, Constant *C2, bool locked) { + return get(Instruction::AShr, C1, C2, locked); } /// getWithOperandReplaced - Return a constant expression identical to this @@ -1251,9 +1277,30 @@ return Result; } + + /// unlockedGetOrCreate - Return the specified constant from the map, + /// creating it if necessary. This version performs no locking, and should + /// only be used during recursive type refinement, when the locks are + /// already held. + ConstantClass *unlockedGetOrCreate(const TypeClass *Ty, const ValType &V) { + MapKey Lookup(Ty, V); + ConstantClass* Result = 0; + + typename MapTy::iterator I = Map.find(Lookup); + // Is it in the map? + if (I != Map.end()) + Result = static_cast(I->second); + + if (!Result) { + // If no preexisting value, create one now... + Result = Create(Ty, V, I); + } + + return Result; + } - void remove(ConstantClass *CP) { - ConstantsLock->writer_acquire(); + void remove(ConstantClass *CP, bool locked = true) { + if (locked) ConstantsLock->writer_acquire(); typename MapTy::iterator I = FindExistingElement(CP); assert(I != Map.end() && "Constant not found in constant table!"); assert(I->second == CP && "Didn't find correct element?"); @@ -1302,7 +1349,7 @@ Map.erase(I); - ConstantsLock->writer_release(); + if (locked) ConstantsLock->writer_release(); } @@ -1392,10 +1439,10 @@ struct ConvertConstantType { static void convert(ConstantAggregateZero *OldC, const Type *NewTy) { // Make everyone now use a constant of the new type... - Constant *New = ConstantAggregateZero::get(NewTy); + Constant *New = ConstantAggregateZero::get(NewTy, false); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. + OldC->destroyConstant(false); // This constant is now dead, destroy it. } }; } @@ -1405,19 +1452,19 @@ static char getValType(ConstantAggregateZero *CPZ) { return 0; } -ConstantAggregateZero *ConstantAggregateZero::get(const Type *Ty) { +ConstantAggregateZero *ConstantAggregateZero::get(const Type *Ty, bool locked) { assert((isa(Ty) || isa(Ty) || isa(Ty)) && "Cannot create an aggregate zero of non-aggregate type!"); - - // Implicitly locked. - return AggZeroConstants->getOrCreate(Ty, 0); + + return locked ? AggZeroConstants->getOrCreate(Ty, 0) : + AggZeroConstants->unlockedGetOrCreate(Ty, 0); } /// destroyConstant - Remove the constant from the constant table... /// -void ConstantAggregateZero::destroyConstant() { +void ConstantAggregateZero::destroyConstant(bool locked) { // Implicitly locked. - AggZeroConstants->remove(this); + AggZeroConstants->remove(this, locked); destroyConstantImpl(); } @@ -1431,10 +1478,10 @@ std::vector C; for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) C.push_back(cast(OldC->getOperand(i))); - Constant *New = ConstantArray::get(NewTy, C); + Constant *New = ConstantArray::get(NewTy, C, false); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. + OldC->destroyConstant(false); // This constant is now dead, destroy it. } }; } @@ -1452,29 +1499,36 @@ static ManagedStatic ArrayConstants; Constant *ConstantArray::get(const ArrayType *Ty, - const std::vector &V) { + const std::vector &V, + bool locked) { // If this is an all-zero array, return a ConstantAggregateZero object if (!V.empty()) { Constant *C = V[0]; if (!C->isNullValue()) { - // Implicitly locked. - return ArrayConstants->getOrCreate(Ty, V); + if (locked) + // Implicitly locked. + return ArrayConstants->getOrCreate(Ty, V); + else + return ArrayConstants->unlockedGetOrCreate(Ty, V); } for (unsigned i = 1, e = V.size(); i != e; ++i) if (V[i] != C) { - // Implicitly locked. - return ArrayConstants->getOrCreate(Ty, V); + if (locked) + // Implicitly locked. + return ArrayConstants->getOrCreate(Ty, V); + else + return ArrayConstants->unlockedGetOrCreate(Ty, V); } } - return ConstantAggregateZero::get(Ty); + return ConstantAggregateZero::get(Ty, locked); } /// destroyConstant - Remove the constant from the constant table... /// -void ConstantArray::destroyConstant() { +void ConstantArray::destroyConstant(bool locked) { // Implicitly locked. - ArrayConstants->remove(this); + ArrayConstants->remove(this, locked); destroyConstantImpl(); } @@ -1484,7 +1538,8 @@ /// Otherwise, the length parameter specifies how much of the string to use /// and it won't be null terminated. /// -Constant *ConstantArray::get(const std::string &Str, bool AddNull) { +Constant *ConstantArray::get(const std::string &Str, + bool AddNull, bool locked) { std::vector ElementVals; for (unsigned i = 0; i < Str.length(); ++i) ElementVals.push_back(ConstantInt::get(Type::Int8Ty, Str[i])); @@ -1495,7 +1550,7 @@ } ArrayType *ATy = ArrayType::get(Type::Int8Ty, ElementVals.size()); - return ConstantArray::get(ATy, ElementVals); + return ConstantArray::get(ATy, ElementVals, locked); } /// isString - This method returns true if the array is an array of i8, and @@ -1559,11 +1614,11 @@ std::vector C; for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) C.push_back(cast(OldC->getOperand(i))); - Constant *New = ConstantStruct::get(NewTy, C); + Constant *New = ConstantStruct::get(NewTy, C, false); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. + OldC->destroyConstant(false); // This constant is now dead, destroy it. } }; } @@ -1581,29 +1636,31 @@ } Constant *ConstantStruct::get(const StructType *Ty, - const std::vector &V) { + const std::vector &V, + bool locked) { // Create a ConstantAggregateZero value if all elements are zeros... for (unsigned i = 0, e = V.size(); i != e; ++i) if (!V[i]->isNullValue()) - // Implicitly locked. - return StructConstants->getOrCreate(Ty, V); + return locked ? StructConstants->getOrCreate(Ty, V) : + StructConstants->unlockedGetOrCreate(Ty, V); - return ConstantAggregateZero::get(Ty); + return ConstantAggregateZero::get(Ty, locked); } -Constant *ConstantStruct::get(const std::vector &V, bool packed) { +Constant *ConstantStruct::get(const std::vector &V, bool packed, + bool locked) { std::vector StructEls; StructEls.reserve(V.size()); for (unsigned i = 0, e = V.size(); i != e; ++i) StructEls.push_back(V[i]->getType()); - return get(StructType::get(StructEls, packed), V); + return get(StructType::get(StructEls, packed), V, locked); } // destroyConstant - Remove the constant from the constant table... // -void ConstantStruct::destroyConstant() { +void ConstantStruct::destroyConstant(bool locked) { // Implicitly locked. - StructConstants->remove(this); + StructConstants->remove(this, locked); destroyConstantImpl(); } @@ -1617,10 +1674,10 @@ std::vector C; for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) C.push_back(cast(OldC->getOperand(i))); - Constant *New = ConstantVector::get(NewTy, C); + Constant *New = ConstantVector::get(NewTy, C, false); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. + OldC->destroyConstant(false); // This constant is now dead, destroy it. } }; } @@ -1637,7 +1694,8 @@ ConstantVector> > VectorConstants; Constant *ConstantVector::get(const VectorType *Ty, - const std::vector &V) { + const std::vector &V, + bool locked) { assert(!V.empty() && "Vectors can't be empty"); // If this is an all-undef or alll-zero vector, return a // ConstantAggregateZero or UndefValue. @@ -1654,24 +1712,24 @@ } if (isZero) - return ConstantAggregateZero::get(Ty); + return ConstantAggregateZero::get(Ty, locked); if (isUndef) - return UndefValue::get(Ty); + return UndefValue::get(Ty, locked); - // Implicitly locked. - return VectorConstants->getOrCreate(Ty, V); + return locked ? VectorConstants->getOrCreate(Ty, V) : + VectorConstants->unlockedGetOrCreate(Ty, V); } -Constant *ConstantVector::get(const std::vector &V) { +Constant *ConstantVector::get(const std::vector &V, bool locked) { assert(!V.empty() && "Cannot infer type if V is empty"); - return get(VectorType::get(V.front()->getType(),V.size()), V); + return get(VectorType::get(V.front()->getType(),V.size()), V, locked); } // destroyConstant - Remove the constant from the constant table... // -void ConstantVector::destroyConstant() { +void ConstantVector::destroyConstant(bool locked) { // Implicitly locked. - VectorConstants->remove(this); + VectorConstants->remove(this, locked); destroyConstantImpl(); } @@ -1718,10 +1776,10 @@ struct ConvertConstantType { static void convert(ConstantPointerNull *OldC, const PointerType *NewTy) { // Make everyone now use a constant of the new type... - Constant *New = ConstantPointerNull::get(NewTy); + Constant *New = ConstantPointerNull::get(NewTy, false); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. + OldC->destroyConstant(false); // This constant is now dead, destroy it. } }; } @@ -1734,16 +1792,18 @@ } -ConstantPointerNull *ConstantPointerNull::get(const PointerType *Ty) { +ConstantPointerNull *ConstantPointerNull::get(const PointerType *Ty, + bool locked) { // Implicitly locked. - return NullPtrConstants->getOrCreate(Ty, 0); + return locked ? NullPtrConstants->getOrCreate(Ty, 0) : + NullPtrConstants->unlockedGetOrCreate(Ty, 0); } // destroyConstant - Remove the constant from the constant table... // -void ConstantPointerNull::destroyConstant() { +void ConstantPointerNull::destroyConstant(bool locked) { // Implicitly locked. - NullPtrConstants->remove(this); + NullPtrConstants->remove(this, locked); destroyConstantImpl(); } @@ -1764,10 +1824,10 @@ struct ConvertConstantType { static void convert(UndefValue *OldC, const Type *NewTy) { // Make everyone now use a constant of the new type. - Constant *New = UndefValue::get(NewTy); + Constant *New = UndefValue::get(NewTy, false); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. + OldC->destroyConstant(false); // This constant is now dead, destroy it. } }; } @@ -1779,16 +1839,16 @@ } -UndefValue *UndefValue::get(const Type *Ty) { - // Implicitly locked. - return UndefValueConstants->getOrCreate(Ty, 0); +UndefValue *UndefValue::get(const Type *Ty, bool locked) { + return locked ? UndefValueConstants->getOrCreate(Ty, 0) : + UndefValueConstants->unlockedGetOrCreate(Ty, 0); } // destroyConstant - Remove the constant from the constant table. // -void UndefValue::destroyConstant() { +void UndefValue::destroyConstant(bool locked) { // Implicitly locked. - UndefValueConstants->remove(this); + UndefValueConstants->remove(this, locked); destroyConstantImpl(); } @@ -1801,21 +1861,25 @@ static ManagedStatic > MDStringCache; -MDString *MDString::get(const char *StrBegin, const char *StrEnd) { - sys::SmartScopedWriter Writer(&*ConstantsLock); +MDString *MDString::get(const char *StrBegin, const char *StrEnd, bool locked) { + if (locked) ConstantsLock->writer_acquire(); + StringMapEntry &Entry = MDStringCache->GetOrCreateValue( StrBegin, StrEnd); MDString *&S = Entry.getValue(); if (!S) S = new MDString(Entry.getKeyData(), Entry.getKeyData() + Entry.getKeyLength()); + if (locked) ConstantsLock->writer_release(); + return S; } -void MDString::destroyConstant() { - sys::SmartScopedWriter Writer(&*ConstantsLock); +void MDString::destroyConstant(bool locked) { + if (locked) ConstantsLock->writer_acquire(); MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd)); destroyConstantImpl(); + if (locked) ConstantsLock->writer_release(); } //---- MDNode::get() implementation @@ -1834,20 +1898,26 @@ ID.AddPointer(*I); } -MDNode *MDNode::get(Value*const* Vals, unsigned NumVals) { +MDNode *MDNode::get(Value*const* Vals, unsigned NumVals, bool locked) { FoldingSetNodeID ID; for (unsigned i = 0; i != NumVals; ++i) ID.AddPointer(Vals[i]); - ConstantsLock->reader_acquire(); + if (locked) ConstantsLock->reader_acquire(); void *InsertPoint; MDNode *N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); - ConstantsLock->reader_release(); + if (locked) ConstantsLock->reader_release(); if (!N) { - sys::SmartScopedWriter Writer(&*ConstantsLock); - N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); - if (!N) { + if (locked) { + sys::SmartScopedWriter Writer(&*ConstantsLock); + N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); + if (!N) { + // InsertPoint will have been set by the FindNodeOrInsertPos call. + N = new(0) MDNode(Vals, NumVals); + MDNodeSet->InsertNode(N, InsertPoint); + } + } else { // InsertPoint will have been set by the FindNodeOrInsertPos call. N = new(0) MDNode(Vals, NumVals); MDNodeSet->InsertNode(N, InsertPoint); @@ -1856,11 +1926,11 @@ return N; } -void MDNode::destroyConstant() { - sys::SmartScopedWriter Writer(&*ConstantsLock); +void MDNode::destroyConstant(bool locked) { + if (locked) ConstantsLock->writer_acquire(); MDNodeSet->RemoveNode(this); - destroyConstantImpl(); + if (locked) ConstantsLock->writer_release(); } //---- ConstantExpr::get() implementations... @@ -1971,30 +2041,30 @@ case Instruction::IntToPtr: case Instruction::BitCast: New = ConstantExpr::getCast(OldC->getOpcode(), OldC->getOperand(0), - NewTy); + NewTy, false); break; case Instruction::Select: New = ConstantExpr::getSelectTy(NewTy, OldC->getOperand(0), OldC->getOperand(1), - OldC->getOperand(2)); + OldC->getOperand(2), false); break; default: assert(OldC->getOpcode() >= Instruction::BinaryOpsBegin && OldC->getOpcode() < Instruction::BinaryOpsEnd); New = ConstantExpr::getTy(NewTy, OldC->getOpcode(), OldC->getOperand(0), - OldC->getOperand(1)); + OldC->getOperand(1), false); break; case Instruction::GetElementPtr: // Make everyone now use a constant of the new type... std::vector Idx(OldC->op_begin()+1, OldC->op_end()); New = ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0), - &Idx[0], Idx.size()); + &Idx[0], Idx.size(), false); break; } assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. + OldC->destroyConstant(false); // This constant is now dead, destroy it. } }; } // end namespace llvm @@ -2017,10 +2087,10 @@ /// This is a utility function to handle folding of casts and lookup of the /// cast in the ExprConstants map. It is used by the various get* methods below. static inline Constant *getFoldedCast( - Instruction::CastOps opc, Constant *C, const Type *Ty) { + Instruction::CastOps opc, Constant *C, const Type *Ty, bool locked) { assert(Ty->isFirstClassType() && "Cannot cast to an aggregate type!"); // Fold a few common cases - if (Constant *FC = ConstantFoldCastInstruction(opc, C, Ty)) + if (Constant *FC = ConstantFoldCastInstruction(opc, C, Ty, locked)) return FC; // Look up the constant in the table first to ensure uniqueness @@ -2028,10 +2098,12 @@ ExprMapKeyType Key(opc, argVec); // Implicitly locked. - return ExprConstants->getOrCreate(Ty, Key); + return locked ? ExprConstants->getOrCreate(Ty, Key) : + ExprConstants->unlockedGetOrCreate(Ty, Key); } -Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty) { +Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty, + bool locked) { Instruction::CastOps opc = Instruction::CastOps(oc); assert(Instruction::isCast(opc) && "opcode out of range"); assert(C && Ty && "Null arguments to getCast"); @@ -2041,18 +2113,18 @@ default: assert(0 && "Invalid cast opcode"); break; - case Instruction::Trunc: return getTrunc(C, Ty); - case Instruction::ZExt: return getZExt(C, Ty); - case Instruction::SExt: return getSExt(C, Ty); - case Instruction::FPTrunc: return getFPTrunc(C, Ty); - case Instruction::FPExt: return getFPExtend(C, Ty); - case Instruction::UIToFP: return getUIToFP(C, Ty); - case Instruction::SIToFP: return getSIToFP(C, Ty); - case Instruction::FPToUI: return getFPToUI(C, Ty); - case Instruction::FPToSI: return getFPToSI(C, Ty); - case Instruction::PtrToInt: return getPtrToInt(C, Ty); - case Instruction::IntToPtr: return getIntToPtr(C, Ty); - case Instruction::BitCast: return getBitCast(C, Ty); + case Instruction::Trunc: return getTrunc(C, Ty, locked); + case Instruction::ZExt: return getZExt(C, Ty, locked); + case Instruction::SExt: return getSExt(C, Ty, locked); + case Instruction::FPTrunc: return getFPTrunc(C, Ty, locked); + case Instruction::FPExt: return getFPExtend(C, Ty, locked); + case Instruction::UIToFP: return getUIToFP(C, Ty, locked); + case Instruction::SIToFP: return getSIToFP(C, Ty, locked); + case Instruction::FPToUI: return getFPToUI(C, Ty, locked); + case Instruction::FPToSI: return getFPToSI(C, Ty, locked); + case Instruction::PtrToInt: return getPtrToInt(C, Ty, locked); + case Instruction::IntToPtr: return getIntToPtr(C, Ty, locked); + case Instruction::BitCast: return getBitCast(C, Ty, locked); } return 0; } @@ -2063,10 +2135,11 @@ return getCast(Instruction::ZExt, C, Ty); } -Constant *ConstantExpr::getSExtOrBitCast(Constant *C, const Type *Ty) { +Constant *ConstantExpr::getSExtOrBitCast(Constant *C, const Type *Ty, + bool locked) { if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) - return getCast(Instruction::BitCast, C, Ty); - return getCast(Instruction::SExt, C, Ty); + return getCast(Instruction::BitCast, C, Ty, locked); + return getCast(Instruction::SExt, C, Ty, locked); } Constant *ConstantExpr::getTruncOrBitCast(Constant *C, const Type *Ty) { @@ -2075,13 +2148,14 @@ return getCast(Instruction::Trunc, C, Ty); } -Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) { +Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty, + bool locked) { assert(isa(S->getType()) && "Invalid cast"); assert((Ty->isInteger() || isa(Ty)) && "Invalid cast"); if (Ty->isInteger()) - return getCast(Instruction::PtrToInt, S, Ty); - return getCast(Instruction::BitCast, S, Ty); + return getCast(Instruction::PtrToInt, S, Ty, locked); + return getCast(Instruction::BitCast, S, Ty, locked); } Constant *ConstantExpr::getIntegerCast(Constant *C, const Type *Ty, @@ -2109,7 +2183,7 @@ return getCast(opcode, C, Ty); } -Constant *ConstantExpr::getTrunc(Constant *C, const Type *Ty) { +Constant *ConstantExpr::getTrunc(Constant *C, const Type *Ty, bool locked) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2120,10 +2194,10 @@ assert(C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& "SrcTy must be larger than DestTy for Trunc!"); - return getFoldedCast(Instruction::Trunc, C, Ty); + return getFoldedCast(Instruction::Trunc, C, Ty, locked); } -Constant *ConstantExpr::getSExt(Constant *C, const Type *Ty) { +Constant *ConstantExpr::getSExt(Constant *C, const Type *Ty, bool locked) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2134,10 +2208,10 @@ assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "SrcTy must be smaller than DestTy for SExt!"); - return getFoldedCast(Instruction::SExt, C, Ty); + return getFoldedCast(Instruction::SExt, C, Ty, locked); } -Constant *ConstantExpr::getZExt(Constant *C, const Type *Ty) { +Constant *ConstantExpr::getZExt(Constant *C, const Type *Ty, bool locked) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2148,10 +2222,10 @@ assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "SrcTy must be smaller than DestTy for ZExt!"); - return getFoldedCast(Instruction::ZExt, C, Ty); + return getFoldedCast(Instruction::ZExt, C, Ty, locked); } -Constant *ConstantExpr::getFPTrunc(Constant *C, const Type *Ty) { +Constant *ConstantExpr::getFPTrunc(Constant *C, const Type *Ty, bool locked) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2160,10 +2234,10 @@ assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& "This is an illegal floating point truncation!"); - return getFoldedCast(Instruction::FPTrunc, C, Ty); + return getFoldedCast(Instruction::FPTrunc, C, Ty, locked); } -Constant *ConstantExpr::getFPExtend(Constant *C, const Type *Ty) { +Constant *ConstantExpr::getFPExtend(Constant *C, const Type *Ty, bool locked) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2172,10 +2246,10 @@ assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "This is an illegal floating point extension!"); - return getFoldedCast(Instruction::FPExt, C, Ty); + return getFoldedCast(Instruction::FPExt, C, Ty, locked); } -Constant *ConstantExpr::getUIToFP(Constant *C, const Type *Ty) { +Constant *ConstantExpr::getUIToFP(Constant *C, const Type *Ty, bool locked) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2183,10 +2257,10 @@ assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert(C->getType()->isIntOrIntVector() && Ty->isFPOrFPVector() && "This is an illegal uint to floating point cast!"); - return getFoldedCast(Instruction::UIToFP, C, Ty); + return getFoldedCast(Instruction::UIToFP, C, Ty, locked); } -Constant *ConstantExpr::getSIToFP(Constant *C, const Type *Ty) { +Constant *ConstantExpr::getSIToFP(Constant *C, const Type *Ty, bool locked) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2194,10 +2268,10 @@ assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert(C->getType()->isIntOrIntVector() && Ty->isFPOrFPVector() && "This is an illegal sint to floating point cast!"); - return getFoldedCast(Instruction::SIToFP, C, Ty); + return getFoldedCast(Instruction::SIToFP, C, Ty, locked); } -Constant *ConstantExpr::getFPToUI(Constant *C, const Type *Ty) { +Constant *ConstantExpr::getFPToUI(Constant *C, const Type *Ty, bool locked) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2205,10 +2279,10 @@ assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert(C->getType()->isFPOrFPVector() && Ty->isIntOrIntVector() && "This is an illegal floating point to uint cast!"); - return getFoldedCast(Instruction::FPToUI, C, Ty); + return getFoldedCast(Instruction::FPToUI, C, Ty, locked); } -Constant *ConstantExpr::getFPToSI(Constant *C, const Type *Ty) { +Constant *ConstantExpr::getFPToSI(Constant *C, const Type *Ty, bool locked) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2216,22 +2290,25 @@ assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert(C->getType()->isFPOrFPVector() && Ty->isIntOrIntVector() && "This is an illegal floating point to sint cast!"); - return getFoldedCast(Instruction::FPToSI, C, Ty); + return getFoldedCast(Instruction::FPToSI, C, Ty, locked); } -Constant *ConstantExpr::getPtrToInt(Constant *C, const Type *DstTy) { +Constant *ConstantExpr::getPtrToInt(Constant *C, const Type *DstTy, + bool locked) { assert(isa(C->getType()) && "PtrToInt source must be pointer"); assert(DstTy->isInteger() && "PtrToInt destination must be integral"); - return getFoldedCast(Instruction::PtrToInt, C, DstTy); + return getFoldedCast(Instruction::PtrToInt, C, DstTy, locked); } -Constant *ConstantExpr::getIntToPtr(Constant *C, const Type *DstTy) { +Constant *ConstantExpr::getIntToPtr(Constant *C, const Type *DstTy, + bool locked) { assert(C->getType()->isInteger() && "IntToPtr source must be integral"); assert(isa(DstTy) && "IntToPtr destination must be a pointer"); - return getFoldedCast(Instruction::IntToPtr, C, DstTy); + return getFoldedCast(Instruction::IntToPtr, C, DstTy, locked); } -Constant *ConstantExpr::getBitCast(Constant *C, const Type *DstTy) { +Constant *ConstantExpr::getBitCast(Constant *C, const Type *DstTy, + bool locked) { // BitCast implies a no-op cast of type only. No bits change. However, you // can't cast pointers to anything but pointers. #ifndef NDEBUG @@ -2251,7 +2328,7 @@ // speedily. if (C->getType() == DstTy) return C; - return getFoldedCast(Instruction::BitCast, C, DstTy); + return getFoldedCast(Instruction::BitCast, C, DstTy, locked); } Constant *ConstantExpr::getAlignOf(const Type *Ty) { @@ -2274,7 +2351,7 @@ } Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode, - Constant *C1, Constant *C2) { + Constant *C1, Constant *C2, bool locked) { // Check the operands for consistency first assert(Opcode >= Instruction::BinaryOpsBegin && Opcode < Instruction::BinaryOpsEnd && @@ -2283,14 +2360,14 @@ "Operand types in binary constant expression should match"); if (ReqTy == C1->getType() || ReqTy == Type::Int1Ty) - if (Constant *FC = ConstantFoldBinaryInstruction(Opcode, C1, C2)) + if (Constant *FC = ConstantFoldBinaryInstruction(Opcode, C1, C2, locked)) return FC; // Fold a few common cases... std::vector argVec(1, C1); argVec.push_back(C2); ExprMapKeyType Key(Opcode, argVec); - // Implicitly locked. - return ExprConstants->getOrCreate(ReqTy, Key); + return locked ? ExprConstants->getOrCreate(ReqTy, Key) : + ExprConstants->unlockedGetOrCreate(ReqTy, Key); } Constant *ConstantExpr::getCompareTy(unsigned short predicate, @@ -2315,7 +2392,8 @@ } } -Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) { +Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2, + bool locked) { // API compatibility: Adjust integer opcodes to floating-point opcodes. if (C1->getType()->isFPOrFPVector()) { if (Opcode == Instruction::Add) Opcode = Instruction::FAdd; @@ -2380,7 +2458,7 @@ } #endif - return getTy(C1->getType(), Opcode, C1, C2); + return getTy(C1->getType(), Opcode, C1, C2, locked); } Constant *ConstantExpr::getCompare(unsigned short pred, @@ -2390,11 +2468,11 @@ } Constant *ConstantExpr::getSelectTy(const Type *ReqTy, Constant *C, - Constant *V1, Constant *V2) { + Constant *V1, Constant *V2, bool locked) { assert(!SelectInst::areInvalidOperands(C, V1, V2)&&"Invalid select operands"); if (ReqTy == V1->getType()) - if (Constant *SC = ConstantFoldSelectInstruction(C, V1, V2)) + if (Constant *SC = ConstantFoldSelectInstruction(C, V1, V2, locked)) return SC; // Fold common cases std::vector argVec(3, C); @@ -2402,19 +2480,20 @@ argVec[2] = V2; ExprMapKeyType Key(Instruction::Select, argVec); - // Implicitly locked. - return ExprConstants->getOrCreate(ReqTy, Key); + return locked ? ExprConstants->getOrCreate(ReqTy, Key) : + ExprConstants->unlockedGetOrCreate(ReqTy, Key); } Constant *ConstantExpr::getGetElementPtrTy(const Type *ReqTy, Constant *C, Value* const *Idxs, - unsigned NumIdx) { + unsigned NumIdx, bool locked) { assert(GetElementPtrInst::getIndexedType(C->getType(), Idxs, Idxs+NumIdx) == cast(ReqTy)->getElementType() && "GEP indices invalid!"); - if (Constant *FC = ConstantFoldGetElementPtr(C, (Constant**)Idxs, NumIdx)) + if (Constant *FC = ConstantFoldGetElementPtr(C, (Constant**)Idxs, + NumIdx, locked)) return FC; // Fold a few common cases... assert(isa(C->getType()) && @@ -2428,22 +2507,24 @@ const ExprMapKeyType Key(Instruction::GetElementPtr, ArgVec); // Implicitly locked. - return ExprConstants->getOrCreate(ReqTy, Key); + return locked ? ExprConstants->getOrCreate(ReqTy, Key) : + ExprConstants->unlockedGetOrCreate(ReqTy, Key); } Constant *ConstantExpr::getGetElementPtr(Constant *C, Value* const *Idxs, - unsigned NumIdx) { + unsigned NumIdx, bool locked) { // Get the result type of the getelementptr! const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(), Idxs, Idxs+NumIdx); assert(Ty && "GEP indices invalid!"); unsigned As = cast(C->getType())->getAddressSpace(); - return getGetElementPtrTy(PointerType::get(Ty, As), C, Idxs, NumIdx); + return getGetElementPtrTy(PointerType::get(Ty, As), C, Idxs, + NumIdx, locked); } Constant *ConstantExpr::getGetElementPtr(Constant *C, Constant* const *Idxs, - unsigned NumIdx) { - return getGetElementPtr(C, (Value* const *)Idxs, NumIdx); + unsigned NumIdx, bool locked) { + return getGetElementPtr(C, (Value* const *)Idxs, NumIdx, locked); } @@ -2722,9 +2803,8 @@ // destroyConstant - Remove the constant from the constant table... // -void ConstantExpr::destroyConstant() { - // Implicitly locked. - ExprConstants->remove(this); +void ConstantExpr::destroyConstant(bool locked) { + ExprConstants->remove(this, locked); destroyConstantImpl(); } @@ -2861,6 +2941,7 @@ Constant *Replacement = 0; if (isAllZeros) { + // We're Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. Modified: llvm/trunk/lib/VMCore/Globals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=73790&r1=73789&r2=73790&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Globals.cpp (original) +++ llvm/trunk/lib/VMCore/Globals.cpp Fri Jun 19 18:16:19 2009 @@ -75,7 +75,7 @@ /// Override destroyConstant to make sure it doesn't get called on /// GlobalValue's because they shouldn't be treated like other constants. -void GlobalValue::destroyConstant() { +void GlobalValue::destroyConstant(bool locked) { assert(0 && "You can't GV->destroyConstant()!"); abort(); } From evan.cheng at apple.com Fri Jun 19 18:17:27 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 19 Jun 2009 23:17:27 -0000 Subject: [llvm-commits] [llvm] r73791 - in /llvm/trunk: lib/Target/ARM/ARMLoadStoreOptimizer.cpp lib/Target/ARM/ARMTargetMachine.cpp test/CodeGen/ARM/ldrd.ll test/CodeGen/ARM/stm.ll Message-ID: <200906192317.n5JNHROP028105@zion.cs.uiuc.edu> Author: evancheng Date: Fri Jun 19 18:17:27 2009 New Revision: 73791 URL: http://llvm.org/viewvc/llvm-project?rev=73791&view=rev Log: Enable arm pre-allocation load / store multiple optimization pass. Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/test/CodeGen/ARM/ldrd.ll llvm/trunk/test/CodeGen/ARM/stm.ll Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=73791&r1=73790&r2=73791&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Fri Jun 19 18:17:27 2009 @@ -32,6 +32,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" using namespace llvm; @@ -992,15 +993,19 @@ return Modified; } -static bool IsSafeToMove(bool isLd, unsigned Base, - MachineBasicBlock::iterator I, - MachineBasicBlock::iterator E, - SmallPtrSet MoveOps, - const TargetRegisterInfo *TRI) { +static bool IsSafeAndProfitableToMove(bool isLd, unsigned Base, + MachineBasicBlock::iterator I, + MachineBasicBlock::iterator E, + SmallPtrSet &MemOps, + SmallSet &MemRegs, + const TargetRegisterInfo *TRI) { // Are there stores / loads / calls between them? // FIXME: This is overly conservative. We should make use of alias information // some day. + SmallSet AddedRegPressure; while (++I != E) { + if (MemOps.count(&*I)) + continue; const TargetInstrDesc &TID = I->getDesc(); if (TID.isCall() || TID.isTerminator() || TID.hasUnmodeledSideEffects()) return false; @@ -1013,16 +1018,26 @@ // str r1, [r0] // strh r5, [r0] // str r4, [r0, #+4] - if (TID.mayStore() && !MoveOps.count(&*I)) + if (TID.mayStore()) return false; } for (unsigned j = 0, NumOps = I->getNumOperands(); j != NumOps; ++j) { MachineOperand &MO = I->getOperand(j); - if (MO.isReg() && MO.isDef() && TRI->regsOverlap(MO.getReg(), Base)) + if (!MO.isReg()) + continue; + unsigned Reg = MO.getReg(); + if (MO.isDef() && TRI->regsOverlap(Reg, Base)) return false; + if (Reg != Base && !MemRegs.count(Reg)) + AddedRegPressure.insert(Reg); } } - return true; + + // Estimate register pressure increase due to the transformation. + if (MemRegs.size() <= 4) + // Ok if we are moving small number of instructions. + return true; + return AddedRegPressure.size() <= MemRegs.size() * 2; } bool @@ -1123,29 +1138,33 @@ LastOffset = Offset; LastBytes = Bytes; LastOpcode = Opcode; - if (++NumMove == 4) + if (++NumMove == 8) // FIXME: Tune break; } if (NumMove <= 1) Ops.pop_back(); else { - SmallPtrSet MoveOps; - for (int i = NumMove-1; i >= 0; --i) - MoveOps.insert(Ops[i]); + SmallPtrSet MemOps; + SmallSet MemRegs; + for (int i = NumMove-1; i >= 0; --i) { + MemOps.insert(Ops[i]); + MemRegs.insert(Ops[i]->getOperand(0).getReg()); + } // Be conservative, if the instructions are too far apart, don't // move them. We want to limit the increase of register pressure. - bool DoMove = (LastLoc - FirstLoc) < NumMove*4; + bool DoMove = (LastLoc - FirstLoc) <= NumMove*4; // FIXME: Tune this. if (DoMove) - DoMove = IsSafeToMove(isLd, Base, FirstOp, LastOp, MoveOps, TRI); + DoMove = IsSafeAndProfitableToMove(isLd, Base, FirstOp, LastOp, + MemOps, MemRegs, TRI); if (!DoMove) { for (unsigned i = 0; i != NumMove; ++i) Ops.pop_back(); } else { // This is the new location for the loads / stores. MachineBasicBlock::iterator InsertPos = isLd ? FirstOp : LastOp; - while (InsertPos != MBB->end() && MoveOps.count(InsertPos)) + while (InsertPos != MBB->end() && MemOps.count(InsertPos)) ++InsertPos; // If we are moving a pair of loads / stores, see if it makes sense @@ -1279,7 +1298,8 @@ } if (StopHere) { - // Found a duplicate (a base+offset combination that's seen earlier). Backtrack. + // Found a duplicate (a base+offset combination that's seen earlier). + // Backtrack. --Loc; break; } Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=73791&r1=73790&r2=73791&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Fri Jun 19 18:17:27 2009 @@ -23,9 +23,6 @@ #include "llvm/Target/TargetOptions.h" using namespace llvm; -static cl::opt -EnablePreLdStOpti("arm-pre-alloc-loadstore-opti", cl::Hidden, - cl::desc("Enable pre-regalloc load store optimization pass")); static cl::opt DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden, cl::desc("Disable load store optimization pass")); static cl::opt DisableIfConversion("disable-arm-if-conversion",cl::Hidden, @@ -155,8 +152,6 @@ bool ARMTargetMachine::addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { - if (!EnablePreLdStOpti) - return false; // FIXME: temporarily disabling load / store optimization pass for Thumb mode. if (OptLevel != CodeGenOpt::None && !DisableLdStOpti && !Subtarget.isThumb()) PM.add(createARMLoadStoreOptimizationPass(true)); Modified: llvm/trunk/test/CodeGen/ARM/ldrd.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/ldrd.ll?rev=73791&r1=73790&r2=73791&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/ldrd.ll (original) +++ llvm/trunk/test/CodeGen/ARM/ldrd.ll Fri Jun 19 18:17:27 2009 @@ -1,6 +1,6 @@ -; RUN: llvm-as < %s | llc -mtriple=armv6-apple-darwin -arm-pre-alloc-loadstore-opti | grep ldrd -; RUN: llvm-as < %s | llc -mtriple=armv5-apple-darwin -arm-pre-alloc-loadstore-opti | not grep ldrd -; RUN: llvm-as < %s | llc -mtriple=armv6-eabi -arm-pre-alloc-loadstore-opti | not grep ldrd +; RUN: llvm-as < %s | llc -mtriple=armv6-apple-darwin | grep ldrd +; RUN: llvm-as < %s | llc -mtriple=armv5-apple-darwin | not grep ldrd +; RUN: llvm-as < %s | llc -mtriple=armv6-eabi | not grep ldrd ; rdar://r6949835 @b = external global i64* Modified: llvm/trunk/test/CodeGen/ARM/stm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/stm.ll?rev=73791&r1=73790&r2=73791&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/stm.ll (original) +++ llvm/trunk/test/CodeGen/ARM/stm.ll Fri Jun 19 18:17:27 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin -mattr=+v6,+vfp2 -arm-pre-alloc-loadstore-opti | grep stm | count 2 +; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin -mattr=+v6,+vfp2 | grep stm | count 2 @"\01LC" = internal constant [32 x i8] c"Boolean Not: %d %d %d %d %d %d\0A\00", section "__TEXT,__cstring,cstring_literals" ; <[32 x i8]*> [#uses=1] @"\01LC1" = internal constant [26 x i8] c"Bitwise Not: %d %d %d %d\0A\00", section "__TEXT,__cstring,cstring_literals" ; <[26 x i8]*> [#uses=1] From dpatel at apple.com Fri Jun 19 18:21:20 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 19 Jun 2009 23:21:20 -0000 Subject: [llvm-commits] [llvm] r73792 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Message-ID: <200906192321.n5JNLKgc028257@zion.cs.uiuc.edu> Author: dpatel Date: Fri Jun 19 18:21:20 2009 New Revision: 73792 URL: http://llvm.org/viewvc/llvm-project?rev=73792&view=rev Log: DwarfWriter is used to emit EH info also. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73792&r1=73791&r2=73792&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Fri Jun 19 18:21:20 2009 @@ -271,7 +271,7 @@ O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; // Emit post-function debug information. - if (TAI->doesSupportDebugInformation()) + if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling()) DW->EndFunction(&MF); // Print out jump tables referenced by the function. @@ -1034,7 +1034,7 @@ } // Emit final debug information. - if (TAI->doesSupportDebugInformation()) + if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling()) DW->EndModule(); // Funny Darwin hack: This flag tells the linker that no global symbols @@ -1054,11 +1054,11 @@ } // Emit final debug information. - if (TAI->doesSupportDebugInformation()) + if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling()) DW->EndModule(); } else if (Subtarget->isTargetELF()) { // Emit final debug information. - if (TAI->doesSupportDebugInformation()) + if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling()) DW->EndModule(); } From gohman at apple.com Fri Jun 19 18:23:28 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Jun 2009 23:23:28 -0000 Subject: [llvm-commits] [llvm] r73793 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/optimize-max-0.ll test/CodeGen/X86/optimize-max-1.ll test/CodeGen/X86/optimize-max-2.ll Message-ID: <200906192323.n5JNNSMe028324@zion.cs.uiuc.edu> Author: djg Date: Fri Jun 19 18:23:27 2009 New Revision: 73793 URL: http://llvm.org/viewvc/llvm-project?rev=73793&view=rev Log: Re-apply r73718, now that the fix in r73787 is in, and add a hand-crafted testcase which demonstrates the bug that was exposed in 254.gap. Added: llvm/trunk/test/CodeGen/X86/optimize-max-2.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp llvm/trunk/test/CodeGen/X86/optimize-max-0.ll llvm/trunk/test/CodeGen/X86/optimize-max-1.ll Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=73793&r1=73792&r2=73793&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Jun 19 18:23:27 2009 @@ -143,10 +143,10 @@ /// inside the loop then try to eliminate the cast opeation. void OptimizeShadowIV(Loop *L); - /// OptimizeSMax - Rewrite the loop's terminating condition - /// if it uses an smax computation. - ICmpInst *OptimizeSMax(Loop *L, ICmpInst *Cond, - IVStrideUse* &CondUse); + /// OptimizeMax - Rewrite the loop's terminating condition + /// if it uses a max computation. + ICmpInst *OptimizeMax(Loop *L, ICmpInst *Cond, + IVStrideUse* &CondUse); bool FindIVUserForCond(ICmpInst *Cond, IVStrideUse *&CondUse, const SCEVHandle *&CondStride); @@ -2044,8 +2044,8 @@ return Cond; } -/// OptimizeSMax - Rewrite the loop's terminating condition if it uses -/// an smax computation. +/// OptimizeMax - Rewrite the loop's terminating condition if it uses +/// a max computation. /// /// This is a narrow solution to a specific, but acute, problem. For loops /// like this: @@ -2055,10 +2055,10 @@ /// p[i] = 0.0; /// } while (++i < n); /// -/// where the comparison is signed, the trip count isn't just 'n', because -/// 'n' could be negative. And unfortunately this can come up even for loops -/// where the user didn't use a C do-while loop. For example, seemingly -/// well-behaved top-test loops will commonly be lowered like this: +/// the trip count isn't just 'n', because 'n' might not be positive. And +/// unfortunately this can come up even for loops where the user didn't use +/// a C do-while loop. For example, seemingly well-behaved top-test loops +/// will commonly be lowered like this: // /// if (n > 0) { /// i = 0; @@ -2071,14 +2071,14 @@ /// test in such a way that indvars can't find it. /// /// When indvars can't find the if test in loops like this, it creates a -/// signed-max expression, which allows it to give the loop a canonical +/// max expression, which allows it to give the loop a canonical /// induction variable: /// /// i = 0; -/// smax = n < 1 ? 1 : n; +/// max = n < 1 ? 1 : n; /// do { /// p[i] = 0.0; -/// } while (++i != smax); +/// } while (++i != max); /// /// Canonical induction variables are necessary because the loop passes /// are designed around them. The most obvious example of this is the @@ -2094,8 +2094,8 @@ /// rewriting their conditions from ICMP_NE back to ICMP_SLT, and deleting /// the instructions for the maximum computation. /// -ICmpInst *LoopStrengthReduce::OptimizeSMax(Loop *L, ICmpInst *Cond, - IVStrideUse* &CondUse) { +ICmpInst *LoopStrengthReduce::OptimizeMax(Loop *L, ICmpInst *Cond, + IVStrideUse* &CondUse) { // Check that the loop matches the pattern we're looking for. if (Cond->getPredicate() != CmpInst::ICMP_EQ && Cond->getPredicate() != CmpInst::ICMP_NE) @@ -2113,17 +2113,19 @@ SCEVHandle IterationCount = SE->getAddExpr(BackedgeTakenCount, One); // Check for a max calculation that matches the pattern. - const SCEVSMaxExpr *SMax = dyn_cast(IterationCount); - if (!SMax || SMax != SE->getSCEV(Sel)) return Cond; + if (!isa(IterationCount) && !isa(IterationCount)) + return Cond; + const SCEVNAryExpr *Max = cast(IterationCount); + if (Max != SE->getSCEV(Sel)) return Cond; // Two handle a max with more than two operands, this optimization would // require additional checking and setup. - if (SMax->getNumOperands() != 2) + if (Max->getNumOperands() != 2) return Cond; - SCEVHandle SMaxLHS = SMax->getOperand(0); - SCEVHandle SMaxRHS = SMax->getOperand(1); - if (!SMaxLHS || SMaxLHS != One) return Cond; + SCEVHandle MaxLHS = Max->getOperand(0); + SCEVHandle MaxRHS = Max->getOperand(1); + if (!MaxLHS || MaxLHS != One) return Cond; // Check the relevant induction variable for conformance to // the pattern. @@ -2140,19 +2142,23 @@ // Check the right operand of the select, and remember it, as it will // be used in the new comparison instruction. Value *NewRHS = 0; - if (SE->getSCEV(Sel->getOperand(1)) == SMaxRHS) + if (SE->getSCEV(Sel->getOperand(1)) == MaxRHS) NewRHS = Sel->getOperand(1); - else if (SE->getSCEV(Sel->getOperand(2)) == SMaxRHS) + else if (SE->getSCEV(Sel->getOperand(2)) == MaxRHS) NewRHS = Sel->getOperand(2); if (!NewRHS) return Cond; + // Determine the new comparison opcode. It may be signed or unsigned, + // and the original comparison may be either equality or inequality. + CmpInst::Predicate Pred = + isa(Max) ? CmpInst::ICMP_SLT : CmpInst::ICMP_ULT; + if (Cond->getPredicate() == CmpInst::ICMP_EQ) + Pred = CmpInst::getInversePredicate(Pred); + // Ok, everything looks ok to change the condition into an SLT or SGE and // delete the max calculation. ICmpInst *NewCond = - new ICmpInst(Cond->getPredicate() == CmpInst::ICMP_NE ? - CmpInst::ICMP_SLT : - CmpInst::ICMP_SGE, - Cond->getOperand(0), NewRHS, "scmp", Cond); + new ICmpInst(Pred, Cond->getOperand(0), NewRHS, "scmp", Cond); // Delete the max calculation instructions. Cond->replaceAllUsesWith(NewCond); @@ -2365,10 +2371,10 @@ StrideNoReuse.insert(*CondStride); } - // If the trip count is computed in terms of an smax (due to ScalarEvolution + // If the trip count is computed in terms of a max (due to ScalarEvolution // being unable to find a sufficient guard, for example), change the loop - // comparison to use SLT instead of NE. - Cond = OptimizeSMax(L, Cond, CondUse); + // comparison to use SLT or ULT instead of NE. + Cond = OptimizeMax(L, Cond, CondUse); // If possible, change stride and operands of the compare instruction to // eliminate one stride. Modified: llvm/trunk/test/CodeGen/X86/optimize-max-0.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/optimize-max-0.ll?rev=73793&r1=73792&r2=73793&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/optimize-max-0.ll (original) +++ llvm/trunk/test/CodeGen/X86/optimize-max-0.ll Fri Jun 19 18:23:27 2009 @@ -1,5 +1,4 @@ ; RUN: llvm-as < %s | llc -march=x86 | not grep cmov -; XFAIL: * ; LSR should be able to eliminate the max computations by ; making the loops use slt/ult comparisons instead of ne comparisons. Modified: llvm/trunk/test/CodeGen/X86/optimize-max-1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/optimize-max-1.ll?rev=73793&r1=73792&r2=73793&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/optimize-max-1.ll (original) +++ llvm/trunk/test/CodeGen/X86/optimize-max-1.ll Fri Jun 19 18:23:27 2009 @@ -1,5 +1,4 @@ ; RUN: llvm-as < %s | llc -march=x86-64 | not grep cmov -; XFAIL: * ; LSR should be able to eliminate both smax and umax expressions ; in loop trip counts. Added: llvm/trunk/test/CodeGen/X86/optimize-max-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/optimize-max-2.ll?rev=73793&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/optimize-max-2.ll (added) +++ llvm/trunk/test/CodeGen/X86/optimize-max-2.ll Fri Jun 19 18:23:27 2009 @@ -0,0 +1,30 @@ +; RUN: llvm-as < %s | llc -march=x86-64 > %t +; RUN: grep cmov %t | count 2 +; RUN: grep jne %t | count 1 + +; LSR's OptimizeMax function shouldn't try to eliminate this max, because +; it has three operands. + +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" + +define void @foo(double* nocapture %p, i64 %x, i64 %y) nounwind { +entry: + %tmp = icmp eq i64 %y, 0 ; [#uses=1] + %umax = select i1 %tmp, i64 1, i64 %y ; [#uses=2] + %tmp8 = icmp ugt i64 %umax, %x ; [#uses=1] + %umax9 = select i1 %tmp8, i64 %umax, i64 %x ; [#uses=1] + br label %bb4 + +bb4: ; preds = %bb4, %entry + %i.07 = phi i64 [ 0, %entry ], [ %2, %bb4 ] ; [#uses=2] + %scevgep = getelementptr double* %p, i64 %i.07 ; [#uses=2] + %0 = load double* %scevgep, align 8 ; [#uses=1] + %1 = fmul double %0, 2.000000e+00 ; [#uses=1] + store double %1, double* %scevgep, align 8 + %2 = add i64 %i.07, 1 ; [#uses=2] + %exitcond = icmp eq i64 %2, %umax9 ; [#uses=1] + br i1 %exitcond, label %return, label %bb4 + +return: ; preds = %bb4 + ret void +} From gohman at apple.com Fri Jun 19 18:29:04 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Jun 2009 23:29:04 -0000 Subject: [llvm-commits] [llvm] r73794 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp Message-ID: <200906192329.n5JNT4lw028483@zion.cs.uiuc.edu> Author: djg Date: Fri Jun 19 18:29:04 2009 New Revision: 73794 URL: http://llvm.org/viewvc/llvm-project?rev=73794&view=rev Log: Make GetMinTrailingZeros a member function of ScalarEvolution, so that it can access the TargetData member (when available) and use ValueTracking.h information to compute information for SCEVUnknown Values. Also add GetMinLeadingZeros and GetMinSignBits functions, with minimal implementations. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=73794&r1=73793&r2=73794&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Fri Jun 19 18:29:04 2009 @@ -571,6 +571,20 @@ /// is deleted. void forgetLoopBackedgeTakenCount(const Loop *L); + /// GetMinTrailingZeros - Determine the minimum number of zero bits that S is + /// guaranteed to end in (at every loop iteration). It is, at the same time, + /// the minimum number of times S is divisible by 2. For example, given {4,+,8} + /// it returns 2. If S is guaranteed to be 0, it returns the bitwidth of S. + uint32_t GetMinTrailingZeros(const SCEVHandle &S); + + /// GetMinLeadingZeros - Determine the minimum number of zero bits that S is + /// guaranteed to begin with (at every loop iteration). + uint32_t GetMinLeadingZeros(const SCEVHandle &S); + + /// GetMinSignBits - Determine the minimum number of sign bits that S is + /// guaranteed to begin with. + uint32_t GetMinSignBits(const SCEVHandle &S); + virtual bool runOnFunction(Function &F); virtual void releaseMemory(); virtual void getAnalysisUsage(AnalysisUsage &AU) const; Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=73794&r1=73793&r2=73794&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Jun 19 18:29:04 2009 @@ -2294,73 +2294,134 @@ /// guaranteed to end in (at every loop iteration). It is, at the same time, /// the minimum number of times S is divisible by 2. For example, given {4,+,8} /// it returns 2. If S is guaranteed to be 0, it returns the bitwidth of S. -static uint32_t GetMinTrailingZeros(SCEVHandle S, const ScalarEvolution &SE) { +uint32_t +ScalarEvolution::GetMinTrailingZeros(const SCEVHandle &S) { if (const SCEVConstant *C = dyn_cast(S)) return C->getValue()->getValue().countTrailingZeros(); if (const SCEVTruncateExpr *T = dyn_cast(S)) - return std::min(GetMinTrailingZeros(T->getOperand(), SE), - (uint32_t)SE.getTypeSizeInBits(T->getType())); + return std::min(GetMinTrailingZeros(T->getOperand()), + (uint32_t)getTypeSizeInBits(T->getType())); if (const SCEVZeroExtendExpr *E = dyn_cast(S)) { - uint32_t OpRes = GetMinTrailingZeros(E->getOperand(), SE); - return OpRes == SE.getTypeSizeInBits(E->getOperand()->getType()) ? - SE.getTypeSizeInBits(E->getType()) : OpRes; + uint32_t OpRes = GetMinTrailingZeros(E->getOperand()); + return OpRes == getTypeSizeInBits(E->getOperand()->getType()) ? + getTypeSizeInBits(E->getType()) : OpRes; } if (const SCEVSignExtendExpr *E = dyn_cast(S)) { - uint32_t OpRes = GetMinTrailingZeros(E->getOperand(), SE); - return OpRes == SE.getTypeSizeInBits(E->getOperand()->getType()) ? - SE.getTypeSizeInBits(E->getType()) : OpRes; + uint32_t OpRes = GetMinTrailingZeros(E->getOperand()); + return OpRes == getTypeSizeInBits(E->getOperand()->getType()) ? + getTypeSizeInBits(E->getType()) : OpRes; } if (const SCEVAddExpr *A = dyn_cast(S)) { // The result is the min of all operands results. - uint32_t MinOpRes = GetMinTrailingZeros(A->getOperand(0), SE); + uint32_t MinOpRes = GetMinTrailingZeros(A->getOperand(0)); for (unsigned i = 1, e = A->getNumOperands(); MinOpRes && i != e; ++i) - MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(A->getOperand(i), SE)); + MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(A->getOperand(i))); return MinOpRes; } if (const SCEVMulExpr *M = dyn_cast(S)) { // The result is the sum of all operands results. - uint32_t SumOpRes = GetMinTrailingZeros(M->getOperand(0), SE); - uint32_t BitWidth = SE.getTypeSizeInBits(M->getType()); + uint32_t SumOpRes = GetMinTrailingZeros(M->getOperand(0)); + uint32_t BitWidth = getTypeSizeInBits(M->getType()); for (unsigned i = 1, e = M->getNumOperands(); SumOpRes != BitWidth && i != e; ++i) - SumOpRes = std::min(SumOpRes + GetMinTrailingZeros(M->getOperand(i), SE), + SumOpRes = std::min(SumOpRes + GetMinTrailingZeros(M->getOperand(i)), BitWidth); return SumOpRes; } if (const SCEVAddRecExpr *A = dyn_cast(S)) { // The result is the min of all operands results. - uint32_t MinOpRes = GetMinTrailingZeros(A->getOperand(0), SE); + uint32_t MinOpRes = GetMinTrailingZeros(A->getOperand(0)); for (unsigned i = 1, e = A->getNumOperands(); MinOpRes && i != e; ++i) - MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(A->getOperand(i), SE)); + MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(A->getOperand(i))); return MinOpRes; } if (const SCEVSMaxExpr *M = dyn_cast(S)) { // The result is the min of all operands results. - uint32_t MinOpRes = GetMinTrailingZeros(M->getOperand(0), SE); + uint32_t MinOpRes = GetMinTrailingZeros(M->getOperand(0)); for (unsigned i = 1, e = M->getNumOperands(); MinOpRes && i != e; ++i) - MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(M->getOperand(i), SE)); + MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(M->getOperand(i))); return MinOpRes; } if (const SCEVUMaxExpr *M = dyn_cast(S)) { // The result is the min of all operands results. - uint32_t MinOpRes = GetMinTrailingZeros(M->getOperand(0), SE); + uint32_t MinOpRes = GetMinTrailingZeros(M->getOperand(0)); for (unsigned i = 1, e = M->getNumOperands(); MinOpRes && i != e; ++i) - MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(M->getOperand(i), SE)); + MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(M->getOperand(i))); return MinOpRes; } - // SCEVUDivExpr, SCEVUnknown + if (const SCEVUnknown *U = dyn_cast(S)) { + // For a SCEVUnknown, ask ValueTracking. + unsigned BitWidth = getTypeSizeInBits(U->getType()); + APInt Mask = APInt::getAllOnesValue(BitWidth); + APInt Zeros(BitWidth, 0), Ones(BitWidth, 0); + ComputeMaskedBits(U->getValue(), Mask, Zeros, Ones); + return Zeros.countTrailingOnes(); + } + + // SCEVUDivExpr return 0; } +uint32_t +ScalarEvolution::GetMinLeadingZeros(const SCEVHandle &S) { + // TODO: Handle other SCEV expression types here. + + if (const SCEVConstant *C = dyn_cast(S)) + return C->getValue()->getValue().countLeadingZeros(); + + if (const SCEVZeroExtendExpr *C = dyn_cast(S)) { + // A zero-extension cast adds zero bits. + return GetMinLeadingZeros(C->getOperand()) + + (getTypeSizeInBits(C->getType()) - + getTypeSizeInBits(C->getOperand()->getType())); + } + + if (const SCEVUnknown *U = dyn_cast(S)) { + // For a SCEVUnknown, ask ValueTracking. + unsigned BitWidth = getTypeSizeInBits(U->getType()); + APInt Mask = APInt::getAllOnesValue(BitWidth); + APInt Zeros(BitWidth, 0), Ones(BitWidth, 0); + ComputeMaskedBits(U->getValue(), Mask, Zeros, Ones, TD); + return Zeros.countLeadingOnes(); + } + + return 1; +} + +uint32_t +ScalarEvolution::GetMinSignBits(const SCEVHandle &S) { + // TODO: Handle other SCEV expression types here. + + if (const SCEVConstant *C = dyn_cast(S)) { + const APInt &A = C->getValue()->getValue(); + return A.isNegative() ? A.countLeadingOnes() : + A.countLeadingZeros(); + } + + if (const SCEVSignExtendExpr *C = dyn_cast(S)) { + // A sign-extension cast adds sign bits. + return GetMinSignBits(C->getOperand()) + + (getTypeSizeInBits(C->getType()) - + getTypeSizeInBits(C->getOperand()->getType())); + } + + if (const SCEVUnknown *U = dyn_cast(S)) { + // For a SCEVUnknown, ask ValueTracking. + return ComputeNumSignBits(U->getValue(), TD); + } + + return 1; +} + /// createSCEV - We know that there is no SCEV for the specified value. /// Analyze the expression. /// @@ -2430,7 +2491,7 @@ if (ConstantInt *CI = dyn_cast(U->getOperand(1))) { SCEVHandle LHS = getSCEV(U->getOperand(0)); const APInt &CIVal = CI->getValue(); - if (GetMinTrailingZeros(LHS, *this) >= + if (GetMinTrailingZeros(LHS) >= (CIVal.getBitWidth() - CIVal.countLeadingZeros())) return getAddExpr(LHS, getSCEV(U->getOperand(1))); } From fvbommel at wxs.nl Fri Jun 19 18:34:11 2009 From: fvbommel at wxs.nl (Frits van Bommel) Date: Sat, 20 Jun 2009 01:34:11 +0200 Subject: [llvm-commits] [llvm] r73787 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp In-Reply-To: <200906192303.n5JN3lOA027645@zion.cs.uiuc.edu> References: <200906192303.n5JN3lOA027645@zion.cs.uiuc.edu> Message-ID: <4A3C2073.6020608@wxs.nl> Dan Gohman wrote: > + // Two handle a max with more than two operands, this optimization would ^^^ Typo. From clattner at apple.com Fri Jun 19 18:37:54 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 19 Jun 2009 16:37:54 -0700 Subject: [llvm-commits] [llvm] r73790 - in /llvm/trunk: include/llvm/Constant.h include/llvm/Constants.h include/llvm/GlobalValue.h include/llvm/MDNode.h lib/VMCore/ConstantFold.cpp lib/VMCore/ConstantFold.h lib/VMCore/Constants.cpp lib/VMCore/Globals.cpp In-Reply-To: <200906192316.n5JNGLLx028062@zion.cs.uiuc.edu> References: <200906192316.n5JNGLLx028062@zion.cs.uiuc.edu> Message-ID: <316146B5-248D-4735-8E04-F079FD6E4C6A@apple.com> On Jun 19, 2009, at 4:16 PM, Owen Anderson wrote: > Author: resistor > Date: Fri Jun 19 18:16:19 2009 > New Revision: 73790 > > URL: http://llvm.org/viewvc/llvm-project?rev=73790&view=rev > Log: > Fix a serious bug that would cause deadlock during abstract type > refinement. The constant creation > gets involved, and we end up trying to recursively acquire a writer > lock. The fix for this is slightly horrible, > and involves passing a boolean "locked" parameter around in > Constants.cpp, but it's better than having locked and > unlocked versions of most of the code. Uh, this is not acceptable. We can't have "locked" escape out the public APIs. -Chris From gohman at apple.com Fri Jun 19 18:41:37 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 19 Jun 2009 23:41:37 -0000 Subject: [llvm-commits] [llvm] r73796 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200906192341.n5JNfb03028847@zion.cs.uiuc.edu> Author: djg Date: Fri Jun 19 18:41:37 2009 New Revision: 73796 URL: http://llvm.org/viewvc/llvm-project?rev=73796&view=rev Log: Fix a typo in a comment that Frits von Bommel noticed. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=73796&r1=73795&r2=73796&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Jun 19 18:41:37 2009 @@ -2118,7 +2118,7 @@ const SCEVNAryExpr *Max = cast(IterationCount); if (Max != SE->getSCEV(Sel)) return Cond; - // Two handle a max with more than two operands, this optimization would + // To handle a max with more than two operands, this optimization would // require additional checking and setup. if (Max->getNumOperands() != 2) return Cond; From sabre at nondot.org Fri Jun 19 18:57:53 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Jun 2009 23:57:53 -0000 Subject: [llvm-commits] [llvm] r73798 - /llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Message-ID: <200906192357.n5JNvrha029339@zion.cs.uiuc.edu> Author: lattner Date: Fri Jun 19 18:57:53 2009 New Revision: 73798 URL: http://llvm.org/viewvc/llvm-project?rev=73798&view=rev Log: allow clients of the asmprinter to opt-out of the boilerplate with a #define. Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=73798&r1=73797&r2=73798&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Fri Jun 19 18:57:53 2009 @@ -651,6 +651,8 @@ O << " processDebugLoc(MI->getDebugLoc());\n\n"; + O << "\n#ifndef NO_ASM_WRITER_BOILERPLATE\n"; + O << " if (MI->getOpcode() == TargetInstrInfo::INLINEASM) {\n" << " O << \"\\t\";\n" << " printInlineAsm(MI);\n" @@ -665,7 +667,9 @@ << " printImplicitDef(MI);\n" << " return true;\n" << " }\n\n"; - + + O << "\n#endif\n"; + O << " O << \"\\t\";\n\n"; O << " // Emit the opcode for the instruction.\n" From sabre at nondot.org Fri Jun 19 18:59:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 19 Jun 2009 23:59:58 -0000 Subject: [llvm-commits] [llvm] r73799 - in /llvm/trunk: include/llvm/CodeGen/MachineInstr.h include/llvm/MC/MCInst.h lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Message-ID: <200906192359.n5JNxwvT029413@zion.cs.uiuc.edu> Author: lattner Date: Fri Jun 19 18:59:57 2009 New Revision: 73799 URL: http://llvm.org/viewvc/llvm-project?rev=73799&view=rev Log: stub out some hacky code for wiring up the new asmprinter interfaces on X86. Not useful yet. Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h llvm/trunk/include/llvm/MC/MCInst.h llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=73799&r1=73798&r2=73799&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Fri Jun 19 18:59:57 2009 @@ -104,7 +104,7 @@ /// getDebugLoc - Returns the debug location id of this MachineInstr. /// - const DebugLoc getDebugLoc() const { return debugLoc; } + DebugLoc getDebugLoc() const { return debugLoc; } /// getDesc - Returns the target instruction descriptor of this /// MachineInstr. Modified: llvm/trunk/include/llvm/MC/MCInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInst.h?rev=73799&r1=73798&r2=73799&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCInst.h (original) +++ llvm/trunk/include/llvm/MC/MCInst.h Fri Jun 19 18:59:57 2009 @@ -19,6 +19,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/DebugLoc.h" namespace llvm { @@ -84,7 +85,10 @@ public: MCInst() : Opcode(~0U) {} + unsigned getOpcode() const { return Opcode; } + DebugLoc getDebugLoc() const { return DebugLoc(); } + const MCOperand &getOperand(unsigned i) const { return Operands[i]; } }; Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73799&r1=73798&r2=73799&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Fri Jun 19 18:59:57 2009 @@ -769,21 +769,17 @@ ++EmittedInsts; if (NewAsmPrinter) { + O << "NEW: "; MCInst TmpInst; // FIXME: Convert TmpInst. - printInstruction(TmpInst); + printInstruction(&TmpInst); + O << "OLD: "; } // Call the autogenerated instruction printer routines. printInstruction(MI); } -/// doInitialization -bool X86ATTAsmPrinter::doInitialization(Module &M) { - return AsmPrinter::doInitialization(M); -} - - void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) { const TargetData *TD = TM.getTargetData(); Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h?rev=73799&r1=73798&r2=73799&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Fri Jun 19 18:59:57 2009 @@ -55,7 +55,6 @@ AsmPrinter::getAnalysisUsage(AU); } - bool doInitialization(Module &M); bool doFinalization(Module &M); /// printInstruction - This method is automatically generated by tablegen @@ -64,8 +63,57 @@ /// returns false. bool printInstruction(const MachineInstr *MI); - bool printInstruction(const MCInst &TmpInst); + + // New MCInst printing stuff. + bool printInstruction(const MCInst *MI); + + void printOperand(const MCInst *MI, unsigned OpNo, + const char *Modifier = 0, bool NotRIPRel = false); + void printMemReference(const MCInst *MI, unsigned Op, + const char *Modifier=NULL, bool NotRIPRel = false); + void printLeaMemReference(const MCInst *MI, unsigned Op, + const char *Modifier=NULL, bool NotRIPRel = false); + void printSSECC(const MCInst *MI, unsigned Op); + void printPICLabel(const MCInst *MI, unsigned Op); + void printi8mem(const MCInst *MI, unsigned OpNo) { + printMemReference(MI, OpNo); + } + void printi16mem(const MCInst *MI, unsigned OpNo) { + printMemReference(MI, OpNo); + } + void printi32mem(const MCInst *MI, unsigned OpNo) { + printMemReference(MI, OpNo); + } + void printi64mem(const MCInst *MI, unsigned OpNo) { + printMemReference(MI, OpNo); + } + void printi128mem(const MCInst *MI, unsigned OpNo) { + printMemReference(MI, OpNo); + } + void printf32mem(const MCInst *MI, unsigned OpNo) { + printMemReference(MI, OpNo); + } + void printf64mem(const MCInst *MI, unsigned OpNo) { + printMemReference(MI, OpNo); + } + void printf80mem(const MCInst *MI, unsigned OpNo) { + printMemReference(MI, OpNo); + } + void printf128mem(const MCInst *MI, unsigned OpNo) { + printMemReference(MI, OpNo); + } + void printlea32mem(const MCInst *MI, unsigned OpNo) { + printLeaMemReference(MI, OpNo); + } + void printlea64mem(const MCInst *MI, unsigned OpNo) { + printLeaMemReference(MI, OpNo); + } + void printlea64_32mem(const MCInst *MI, unsigned OpNo) { + printLeaMemReference(MI, OpNo, "subreg64"); + } + + // These methods are used by the tablegen'erated instruction printer. void printOperand(const MachineInstr *MI, unsigned OpNo, Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=73799&r1=73798&r2=73799&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Fri Jun 19 18:59:57 2009 @@ -15,8 +15,46 @@ #define DEBUG_TYPE "asm-printer" #include "llvm/MC/MCInst.h" #include "X86ATTAsmPrinter.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; -bool X86ATTAsmPrinter::printInstruction(const MCInst &TmpInst) { - return true; -} \ No newline at end of file +// Include the auto-generated portion of the assembly writer. +#define MachineInstr MCInst +#define NO_ASM_WRITER_BOILERPLATE +#include "X86GenAsmWriter.inc" +#undef MachineInstr + +void X86ATTAsmPrinter::printSSECC(const MCInst *MI, unsigned Op) { + unsigned char value = MI->getOperand(Op).getImm(); + assert(value <= 7 && "Invalid ssecc argument!"); + switch (value) { + case 0: O << "eq"; break; + case 1: O << "lt"; break; + case 2: O << "le"; break; + case 3: O << "unord"; break; + case 4: O << "neq"; break; + case 5: O << "nlt"; break; + case 6: O << "nle"; break; + case 7: O << "ord"; break; + } +} + + +void X86ATTAsmPrinter::printPICLabel(const MCInst *MI, unsigned Op) { + assert(0 && + "This is only used for MOVPC32r, should lower before asm printing!"); +} + + +void X86ATTAsmPrinter::printOperand(const MCInst *MI, unsigned OpNo, + const char *Modifier, bool NotRIPRel) { +} + +void X86ATTAsmPrinter::printLeaMemReference(const MCInst *MI, unsigned Op, + const char *Modifier, + bool NotRIPRel) { +} + +void X86ATTAsmPrinter::printMemReference(const MCInst *MI, unsigned Op, + const char *Modifier, bool NotRIPRel){ +} From resistor at mac.com Fri Jun 19 19:24:58 2009 From: resistor at mac.com (Owen Anderson) Date: Sat, 20 Jun 2009 00:24:58 -0000 Subject: [llvm-commits] [llvm] r73801 - in /llvm/trunk: include/llvm/Constant.h include/llvm/Constants.h include/llvm/GlobalValue.h include/llvm/MDNode.h lib/VMCore/ConstantFold.cpp lib/VMCore/Constants.cpp lib/VMCore/Globals.cpp Message-ID: <200906200024.n5K0Owpn030186@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 19:24:58 2009 New Revision: 73801 URL: http://llvm.org/viewvc/llvm-project?rev=73801&view=rev Log: Revert r73790, and replace it with a significantly less ugly solution. Rather than trying to make the global reader-writer lock work, create separate recursive mutexes for each value map. The recursive-ness fixes the double-acquiring issue, which having one per ValueMap lets us continue to maintain some concurrency. Modified: llvm/trunk/include/llvm/Constant.h llvm/trunk/include/llvm/Constants.h llvm/trunk/include/llvm/GlobalValue.h llvm/trunk/include/llvm/MDNode.h llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Globals.cpp Modified: llvm/trunk/include/llvm/Constant.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constant.h?rev=73801&r1=73800&r2=73801&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constant.h (original) +++ llvm/trunk/include/llvm/Constant.h Fri Jun 19 19:24:58 2009 @@ -61,7 +61,7 @@ public: /// Static constructor to get a '0' constant of arbitrary type... /// - static Constant *getNullValue(const Type *Ty, bool locked = true); + static Constant *getNullValue(const Type *Ty); /// Static constructor to get a '-1' constant. This supports integers and /// vectors. @@ -107,9 +107,7 @@ /// available cached constants. Implementations should call /// destroyConstantImpl as the last thing they do, to destroy all users and /// delete this. - virtual void destroyConstant(bool locked = true) { - assert(0 && "Not reached!"); - } + virtual void destroyConstant() { assert(0 && "Not reached!"); } //// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Constant *) { return true; } Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=73801&r1=73800&r2=73801&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Fri Jun 19 19:24:58 2009 @@ -109,13 +109,11 @@ /// the type. /// @brief Get a ConstantInt for a specific value. static ConstantInt *get(const IntegerType *Ty, - uint64_t V, bool isSigned = false, - bool locked = true); + uint64_t V, bool isSigned = false); /// If Ty is a vector type, return a Constant with a splat of the given /// value. Otherwise return a ConstantInt for the given value. - static Constant *get(const Type *Ty, uint64_t V, - bool isSigned = false, bool locked = true); + static Constant *get(const Type *Ty, uint64_t V, bool isSigned = false); /// Return a ConstantInt with the specified value for the specified type. The /// value V will be canonicalized to a an unsigned APInt. Accessing it with @@ -131,11 +129,11 @@ /// Return a ConstantInt with the specified value and an implied Type. The /// type is the integer type that corresponds to the bit width of the value. - static ConstantInt *get(const APInt &V, bool locked = true); + static ConstantInt *get(const APInt &V); /// If Ty is a vector type, return a Constant with a splat of the given /// value. Otherwise return a ConstantInt for the given value. - static Constant *get(const Type *Ty, const APInt &V, bool locked = true); + static Constant *get(const Type *Ty, const APInt &V); /// getType - Specialize the getType() method to always return an IntegerType, /// which reduces the amount of casting needed in parts of the compiler. @@ -232,7 +230,7 @@ /// @returns the value for an integer constant of the given type that has all /// its bits set to true. /// @brief Get the all ones value - static ConstantInt *getAllOnesValue(const Type *Ty, bool locked = true); + static ConstantInt *getAllOnesValue(const Type *Ty); /// @brief Methods to support type inquiry through isa, cast, and dyn_cast. static inline bool classof(const ConstantInt *) { return true; } @@ -261,13 +259,13 @@ } public: /// get() - Static factory methods - Return objects of the specified value - static ConstantFP *get(const APFloat &V, bool locked = true); + static ConstantFP *get(const APFloat &V); /// get() - This returns a ConstantFP, or a vector containing a splat of a /// ConstantFP, for the specified value in the specified type. This should /// only be used for simple constant values like 2.0/1.0 etc, that are /// known-valid both as host double and as the target format. - static Constant *get(const Type *Ty, double V, bool locked = true); + static Constant *get(const Type *Ty, double V); /// isValueValidForType - return true if Ty is big enough to represent V. static bool isValueValidForType(const Type *Ty, const APFloat& V); @@ -323,13 +321,13 @@ public: /// get() - static factory method for creating a null aggregate. It is /// illegal to call this method with a non-aggregate type. - static ConstantAggregateZero *get(const Type *Ty, bool locked = true); + static ConstantAggregateZero *get(const Type *Ty); /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. virtual bool isNullValue() const { return true; } - virtual void destroyConstant(bool locked = true); + virtual void destroyConstant(); /// Methods for support type inquiry through isa, cast, and dyn_cast: /// @@ -351,11 +349,9 @@ ConstantArray(const ArrayType *T, const std::vector &Val); public: /// get() - Static factory methods - Return objects of the specified value - static Constant *get(const ArrayType *T, const std::vector &, - bool locked = true); + static Constant *get(const ArrayType *T, const std::vector &); static Constant *get(const ArrayType *T, - Constant*const*Vals, unsigned NumVals, - bool locked = true) { + Constant*const*Vals, unsigned NumVals) { // FIXME: make this the primary ctor method. return get(T, std::vector(Vals, Vals+NumVals)); } @@ -366,8 +362,7 @@ /// of the array by one (you've been warned). However, in some situations /// this is not desired so if AddNull==false then the string is copied without /// null termination. - static Constant *get(const std::string &Initializer, - bool AddNull = true, bool locked = true); + static Constant *get(const std::string &Initializer, bool AddNull = true); /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); @@ -400,7 +395,7 @@ /// created as ConstantAggregateZero objects. virtual bool isNullValue() const { return false; } - virtual void destroyConstant(bool locked = true); + virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -428,14 +423,12 @@ public: /// get() - Static factory methods - Return objects of the specified value /// - static Constant *get(const StructType *T, const std::vector &V, - bool locked = true); - static Constant *get(const std::vector &V, bool Packed = false, - bool locked = true); + static Constant *get(const StructType *T, const std::vector &V); + static Constant *get(const std::vector &V, bool Packed = false); static Constant *get(Constant*const* Vals, unsigned NumVals, - bool Packed = false, bool locked = true) { + bool Packed = false) { // FIXME: make this the primary ctor method. - return get(std::vector(Vals, Vals+NumVals), Packed, locked); + return get(std::vector(Vals, Vals+NumVals), Packed); } /// Transparently provide more efficient getOperand methods. @@ -454,7 +447,7 @@ return false; } - virtual void destroyConstant(bool locked = true); + virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -481,13 +474,11 @@ ConstantVector(const VectorType *T, const std::vector &Val); public: /// get() - Static factory methods - Return objects of the specified value - static Constant *get(const VectorType *T, const std::vector &, - bool locked = true); - static Constant *get(const std::vector &V, bool locked = true); - static Constant *get(Constant*const* Vals, unsigned NumVals, - bool locked = true) { + static Constant *get(const VectorType *T, const std::vector &); + static Constant *get(const std::vector &V); + static Constant *get(Constant*const* Vals, unsigned NumVals) { // FIXME: make this the primary ctor method. - return get(std::vector(Vals, Vals+NumVals), locked); + return get(std::vector(Vals, Vals+NumVals)); } /// Transparently provide more efficient getOperand methods. @@ -503,8 +494,7 @@ /// @returns the value for a vector integer constant of the given type that /// has all its bits set to true. /// @brief Get the all ones value - static ConstantVector *getAllOnesValue(const VectorType *Ty, - bool locked = true); + static ConstantVector *getAllOnesValue(const VectorType *Ty); /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. This always returns false because zero vectors are always @@ -521,7 +511,7 @@ /// elements have the same value, return that value. Otherwise return NULL. Constant *getSplatValue(); - virtual void destroyConstant(bool locked = true); + virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -556,13 +546,13 @@ } public: /// get() - Static factory methods - Return objects of the specified value - static ConstantPointerNull *get(const PointerType *T, bool locked = true); + static ConstantPointerNull *get(const PointerType *T); /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. virtual bool isNullValue() const { return true; } - virtual void destroyConstant(bool locked = true); + virtual void destroyConstant(); /// getType - Specialize the getType() method to always return an PointerType, /// which reduces the amount of casting needed in parts of the compiler. @@ -600,14 +590,13 @@ // These private methods are used by the type resolution code to create // ConstantExprs in intermediate forms. static Constant *getTy(const Type *Ty, unsigned Opcode, - Constant *C1, Constant *C2, bool locked = true); + Constant *C1, Constant *C2); static Constant *getCompareTy(unsigned short pred, Constant *C1, Constant *C2); - static Constant *getSelectTy(const Type *Ty, Constant *C1, Constant *C2, - Constant *C3, bool locked = true); + static Constant *getSelectTy(const Type *Ty, + Constant *C1, Constant *C2, Constant *C3); static Constant *getGetElementPtrTy(const Type *Ty, Constant *C, - Value* const *Idxs, unsigned NumIdxs, - bool locked = true); + Value* const *Idxs, unsigned NumIdxs); static Constant *getExtractElementTy(const Type *Ty, Constant *Val, Constant *Idx); static Constant *getInsertElementTy(const Type *Ty, Constant *Val, @@ -628,18 +617,18 @@ /// Cast constant expr /// - static Constant *getTrunc (Constant *C, const Type *Ty, bool locked = true); - static Constant *getSExt (Constant *C, const Type *Ty, bool locked = true); - static Constant *getZExt (Constant *C, const Type *Ty, bool locked = true); - static Constant *getFPTrunc (Constant *C, const Type *Ty, bool locked = true); - static Constant *getFPExtend(Constant *C, const Type *Ty, bool locked = true); - static Constant *getUIToFP (Constant *C, const Type *Ty, bool locked = true); - static Constant *getSIToFP (Constant *C, const Type *Ty, bool locked = true); - static Constant *getFPToUI (Constant *C, const Type *Ty, bool locked = true); - static Constant *getFPToSI (Constant *C, const Type *Ty, bool locked = true); - static Constant *getPtrToInt(Constant *C, const Type *Ty, bool locked = true); - static Constant *getIntToPtr(Constant *C, const Type *Ty, bool locked = true); - static Constant *getBitCast (Constant *C, const Type *Ty, bool locked = true); + static Constant *getTrunc (Constant *C, const Type *Ty); + static Constant *getSExt (Constant *C, const Type *Ty); + static Constant *getZExt (Constant *C, const Type *Ty); + static Constant *getFPTrunc (Constant *C, const Type *Ty); + static Constant *getFPExtend(Constant *C, const Type *Ty); + static Constant *getUIToFP (Constant *C, const Type *Ty); + static Constant *getSIToFP (Constant *C, const Type *Ty); + static Constant *getFPToUI (Constant *C, const Type *Ty); + static Constant *getFPToSI (Constant *C, const Type *Ty); + static Constant *getPtrToInt(Constant *C, const Type *Ty); + static Constant *getIntToPtr(Constant *C, const Type *Ty); + static Constant *getBitCast (Constant *C, const Type *Ty); /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); @@ -649,8 +638,7 @@ static Constant *getCast( unsigned ops, ///< The opcode for the conversion Constant *C, ///< The constant to be converted - const Type *Ty, ///< The type to which the constant is converted - bool locked = true + const Type *Ty ///< The type to which the constant is converted ); // @brief Create a ZExt or BitCast cast constant expression @@ -662,8 +650,7 @@ // @brief Create a SExt or BitCast cast constant expression static Constant *getSExtOrBitCast( Constant *C, ///< The constant to sext or bitcast - const Type *Ty, ///< The type to sext or bitcast C to - bool locked = true + const Type *Ty ///< The type to sext or bitcast C to ); // @brief Create a Trunc or BitCast cast constant expression @@ -675,8 +662,7 @@ /// @brief Create a BitCast or a PtrToInt cast constant expression static Constant *getPointerCast( Constant *C, ///< The pointer value to be casted (operand 0) - const Type *Ty, ///< The type to which cast should be made - bool locked = true + const Type *Ty ///< The type to which cast should be made ); /// @brief Create a ZExt, Bitcast or Trunc for integer -> integer casts @@ -722,8 +708,7 @@ /// ConstantExpr::get - Return a binary or shift operator constant expression, /// folding if possible. /// - static Constant *get(unsigned Opcode, Constant *C1, Constant *C2, - bool locked = true); + static Constant *get(unsigned Opcode, Constant *C1, Constant *C2); /// @brief Return an ICmp, FCmp, VICmp, or VFCmp comparison operator constant /// expression. @@ -735,38 +720,36 @@ static Constant *getNeg(Constant *C); static Constant *getFNeg(Constant *C); static Constant *getNot(Constant *C); - static Constant *getAdd(Constant *C1, Constant *C2, bool locked = true); - static Constant *getFAdd(Constant *C1, Constant *C2, bool locked = true); - static Constant *getSub(Constant *C1, Constant *C2, bool locked = true); - static Constant *getFSub(Constant *C1, Constant *C2, bool locked = true); - static Constant *getMul(Constant *C1, Constant *C2, bool locked = true); - static Constant *getFMul(Constant *C1, Constant *C2, bool locked = true); - static Constant *getUDiv(Constant *C1, Constant *C2, bool locked = true); - static Constant *getSDiv(Constant *C1, Constant *C2, bool locked = true); - static Constant *getFDiv(Constant *C1, Constant *C2, bool locked = true); - // unsigned rem - static Constant *getURem(Constant *C1, Constant *C2, bool locked = true); - // signed rem - static Constant *getSRem(Constant *C1, Constant *C2, bool locked = true); - static Constant *getFRem(Constant *C1, Constant *C2, bool locked = true); - static Constant *getAnd(Constant *C1, Constant *C2, bool locked = true); - static Constant *getOr(Constant *C1, Constant *C2, bool locked = true); - static Constant *getXor(Constant *C1, Constant *C2, bool locked = true); + static Constant *getAdd(Constant *C1, Constant *C2); + static Constant *getFAdd(Constant *C1, Constant *C2); + static Constant *getSub(Constant *C1, Constant *C2); + static Constant *getFSub(Constant *C1, Constant *C2); + static Constant *getMul(Constant *C1, Constant *C2); + static Constant *getFMul(Constant *C1, Constant *C2); + static Constant *getUDiv(Constant *C1, Constant *C2); + static Constant *getSDiv(Constant *C1, Constant *C2); + static Constant *getFDiv(Constant *C1, Constant *C2); + static Constant *getURem(Constant *C1, Constant *C2); // unsigned rem + static Constant *getSRem(Constant *C1, Constant *C2); // signed rem + static Constant *getFRem(Constant *C1, Constant *C2); + static Constant *getAnd(Constant *C1, Constant *C2); + static Constant *getOr(Constant *C1, Constant *C2); + static Constant *getXor(Constant *C1, Constant *C2); static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getVICmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getVFCmp(unsigned short pred, Constant *LHS, Constant *RHS); - static Constant *getShl(Constant *C1, Constant *C2, bool locked = true); - static Constant *getLShr(Constant *C1, Constant *C2, bool locked = true); - static Constant *getAShr(Constant *C1, Constant *C2, bool locked = true); + static Constant *getShl(Constant *C1, Constant *C2); + static Constant *getLShr(Constant *C1, Constant *C2); + static Constant *getAShr(Constant *C1, Constant *C2); /// Getelementptr form. std::vector is only accepted for convenience: /// all elements must be Constant's. /// - static Constant *getGetElementPtr(Constant *C, Constant* const *IdxList, - unsigned NumIdx, bool locked = true); - static Constant *getGetElementPtr(Constant *C, Value* const *IdxList, - unsigned NumIdx, bool locked = true); + static Constant *getGetElementPtr(Constant *C, + Constant* const *IdxList, unsigned NumIdx); + static Constant *getGetElementPtr(Constant *C, + Value* const *IdxList, unsigned NumIdx); static Constant *getExtractElement(Constant *Vec, Constant *Idx); static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx); @@ -811,7 +794,7 @@ } Constant *getWithOperands(Constant* const *Ops, unsigned NumOps) const; - virtual void destroyConstant(bool locked = true); + virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U); /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -848,13 +831,13 @@ /// get() - Static factory methods - Return an 'undef' object of the specified /// type. /// - static UndefValue *get(const Type *T, bool locked = true); + static UndefValue *get(const Type *T); /// isNullValue - Return true if this is the value that would be returned by /// getNullValue. virtual bool isNullValue() const { return false; } - virtual void destroyConstant(bool locked = true); + virtual void destroyConstant(); /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const UndefValue *) { return true; } @@ -881,8 +864,7 @@ public: /// get() - Static factory methods - Return objects of the specified value. /// - static MDString *get(const char *StrBegin, const char *StrEnd, - bool locked = true); + static MDString *get(const char *StrBegin, const char *StrEnd); /// size() - The length of this string. /// @@ -909,7 +891,7 @@ return false; } - virtual void destroyConstant(bool locked = true); + virtual void destroyConstant(); /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const MDString *) { return true; } Modified: llvm/trunk/include/llvm/GlobalValue.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalValue.h?rev=73801&r1=73800&r2=73801&view=diff ============================================================================== --- llvm/trunk/include/llvm/GlobalValue.h (original) +++ llvm/trunk/include/llvm/GlobalValue.h Fri Jun 19 19:24:58 2009 @@ -172,7 +172,7 @@ virtual bool isNullValue() const { return false; } /// Override from Constant class. - virtual void destroyConstant(bool locked = true); + virtual void destroyConstant(); /// isDeclaration - Return true if the primary definition of this global /// value is outside of the current translation unit... Modified: llvm/trunk/include/llvm/MDNode.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MDNode.h?rev=73801&r1=73800&r2=73801&view=diff ============================================================================== --- llvm/trunk/include/llvm/MDNode.h (original) +++ llvm/trunk/include/llvm/MDNode.h Fri Jun 19 19:24:58 2009 @@ -78,7 +78,7 @@ /// get() - Static factory methods - Return objects of the specified value. /// - static MDNode *get(Value*const* Vals, unsigned NumVals, bool locked = true); + static MDNode *get(Value*const* Vals, unsigned NumVals); Value *getElement(unsigned i) const { return Node[i]; @@ -117,7 +117,7 @@ /// duplicates void Profile(FoldingSetNodeID &ID) const; - virtual void destroyConstant(bool locked = true); + virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) { assert(0 && "This should never be called because MDNodes have no ops"); abort(); Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=73801&r1=73800&r2=73801&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Fri Jun 19 19:24:58 2009 @@ -40,8 +40,7 @@ /// specified vector type. At this point, we know that the elements of the /// input vector constant are all simple integer or FP values. static Constant *BitCastConstantVector(ConstantVector *CV, - const VectorType *DstTy, - bool locked) { + const VectorType *DstTy) { // If this cast changes element count then we can't handle it here: // doing so requires endianness information. This should be handled by // Analysis/ConstantFolding.cpp @@ -61,7 +60,7 @@ const Type *DstEltTy = DstTy->getElementType(); for (unsigned i = 0; i != NumElts; ++i) Result.push_back(ConstantExpr::getBitCast(CV->getOperand(i), DstEltTy)); - return ConstantVector::get(Result, locked); + return ConstantVector::get(Result); } /// This function determines which opcode to use to fold two constant cast @@ -89,8 +88,7 @@ Type::Int64Ty); } -static Constant *FoldBitCast(Constant *V, const Type *DestTy, - bool locked = true) { +static Constant *FoldBitCast(Constant *V, const Type *DestTy) { const Type *SrcTy = V->getType(); if (SrcTy == DestTy) return V; // no-op cast @@ -101,7 +99,7 @@ if (const PointerType *DPTy = dyn_cast(DestTy)) if (PTy->getAddressSpace() == DPTy->getAddressSpace()) { SmallVector IdxList; - IdxList.push_back(Constant::getNullValue(Type::Int32Ty, locked)); + IdxList.push_back(Constant::getNullValue(Type::Int32Ty)); const Type *ElTy = PTy->getElementType(); while (ElTy != DPTy->getElementType()) { if (const StructType *STy = dyn_cast(ElTy)) { @@ -119,8 +117,7 @@ } if (ElTy == DPTy->getElementType()) - return ConstantExpr::getGetElementPtr(V, &IdxList[0], - IdxList.size(), locked); + return ConstantExpr::getGetElementPtr(V, &IdxList[0], IdxList.size()); } // Handle casts from one vector constant to another. We know that the src @@ -132,24 +129,23 @@ SrcTy = NULL; // First, check for null. Undef is already handled. if (isa(V)) - return Constant::getNullValue(DestTy, locked); + return Constant::getNullValue(DestTy); if (ConstantVector *CV = dyn_cast(V)) - return BitCastConstantVector(CV, DestPTy, locked); + return BitCastConstantVector(CV, DestPTy); } // Canonicalize scalar-to-vector bitcasts into vector-to-vector bitcasts // This allows for other simplifications (although some of them // can only be handled by Analysis/ConstantFolding.cpp). if (isa(V) || isa(V)) - return ConstantExpr::getBitCast(ConstantVector::get(&V, 1, locked), - DestPTy, locked); + return ConstantExpr::getBitCast(ConstantVector::get(&V, 1), DestPTy); } // Finally, implement bitcast folding now. The code below doesn't handle // bitcast right. if (isa(V)) // ptr->ptr cast. - return ConstantPointerNull::get(cast(DestTy), locked); + return ConstantPointerNull::get(cast(DestTy)); // Handle integral constant input. if (const ConstantInt *CI = dyn_cast(V)) { @@ -160,7 +156,7 @@ if (DestTy->isFloatingPoint()) return ConstantFP::get(APFloat(CI->getValue(), - DestTy != Type::PPC_FP128Ty), locked); + DestTy != Type::PPC_FP128Ty)); // Otherwise, can't fold this (vector?) return 0; @@ -169,22 +165,22 @@ // Handle ConstantFP input. if (const ConstantFP *FP = dyn_cast(V)) // FP -> Integral. - return ConstantInt::get(FP->getValueAPF().bitcastToAPInt(), locked); + return ConstantInt::get(FP->getValueAPF().bitcastToAPInt()); return 0; } Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V, - const Type *DestTy, bool locked) { + const Type *DestTy) { if (isa(V)) { // zext(undef) = 0, because the top bits will be zero. // sext(undef) = 0, because the top bits will all be the same. // [us]itofp(undef) = 0, because the result value is bounded. if (opc == Instruction::ZExt || opc == Instruction::SExt || opc == Instruction::UIToFP || opc == Instruction::SIToFP) - return Constant::getNullValue(DestTy, locked); - return UndefValue::get(DestTy, locked); + return Constant::getNullValue(DestTy); + return UndefValue::get(DestTy); } // No compile-time operations on this type yet. if (V->getType() == Type::PPC_FP128Ty || DestTy == Type::PPC_FP128Ty) @@ -196,7 +192,7 @@ if (CE->isCast()) { // Try hard to fold cast of cast because they are often eliminable. if (unsigned newOpc = foldConstantCastPair(opc, CE, DestTy)) - return ConstantExpr::getCast(newOpc, CE->getOperand(0), DestTy, locked); + return ConstantExpr::getCast(newOpc, CE->getOperand(0), DestTy); } else if (CE->getOpcode() == Instruction::GetElementPtr) { // If all of the indexes in the GEP are null values, there is no pointer // adjustment going on. We might as well cast the source pointer. @@ -208,7 +204,7 @@ } if (isAllNull) // This is casting one pointer type to another, always BitCast - return ConstantExpr::getPointerCast(CE->getOperand(0), DestTy, locked); + return ConstantExpr::getPointerCast(CE->getOperand(0), DestTy); } } @@ -224,8 +220,8 @@ const Type *DstEltTy = DestVecTy->getElementType(); for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) res.push_back(ConstantExpr::getCast(opc, - CV->getOperand(i), DstEltTy, locked)); - return ConstantVector::get(DestVecTy, res, locked); + CV->getOperand(i), DstEltTy)); + return ConstantVector::get(DestVecTy, res); } // We actually have to do a cast now. Perform the cast according to the @@ -242,7 +238,7 @@ DestTy == Type::FP128Ty ? APFloat::IEEEquad : APFloat::Bogus, APFloat::rmNearestTiesToEven, &ignored); - return ConstantFP::get(Val, locked); + return ConstantFP::get(Val); } return 0; // Can't fold. case Instruction::FPToUI: @@ -255,16 +251,16 @@ (void) V.convertToInteger(x, DestBitWidth, opc==Instruction::FPToSI, APFloat::rmTowardZero, &ignored); APInt Val(DestBitWidth, 2, x); - return ConstantInt::get(Val, locked); + return ConstantInt::get(Val); } return 0; // Can't fold. case Instruction::IntToPtr: //always treated as unsigned if (V->isNullValue()) // Is it an integral null value? - return ConstantPointerNull::get(cast(DestTy), locked); + return ConstantPointerNull::get(cast(DestTy)); return 0; // Other pointer types cannot be casted case Instruction::PtrToInt: // always treated as unsigned if (V->isNullValue()) // is it a null pointer value? - return ConstantInt::get(DestTy, 0, locked); + return ConstantInt::get(DestTy, 0); return 0; // Other pointer types cannot be casted case Instruction::UIToFP: case Instruction::SIToFP: @@ -276,7 +272,7 @@ (void)apf.convertFromAPInt(api, opc==Instruction::SIToFP, APFloat::rmNearestTiesToEven); - return ConstantFP::get(apf, locked); + return ConstantFP::get(apf); } return 0; case Instruction::ZExt: @@ -284,7 +280,7 @@ uint32_t BitWidth = cast(DestTy)->getBitWidth(); APInt Result(CI->getValue()); Result.zext(BitWidth); - return ConstantInt::get(Result, locked); + return ConstantInt::get(Result); } return 0; case Instruction::SExt: @@ -292,7 +288,7 @@ uint32_t BitWidth = cast(DestTy)->getBitWidth(); APInt Result(CI->getValue()); Result.sext(BitWidth); - return ConstantInt::get(Result, locked); + return ConstantInt::get(Result); } return 0; case Instruction::Trunc: @@ -300,11 +296,11 @@ uint32_t BitWidth = cast(DestTy)->getBitWidth(); APInt Result(CI->getValue()); Result.trunc(BitWidth); - return ConstantInt::get(Result, locked); + return ConstantInt::get(Result); } return 0; case Instruction::BitCast: - return FoldBitCast(const_cast(V), DestTy, locked); + return FoldBitCast(const_cast(V), DestTy); default: assert(!"Invalid CE CastInst opcode"); break; @@ -316,7 +312,7 @@ Constant *llvm::ConstantFoldSelectInstruction(const Constant *Cond, const Constant *V1, - const Constant *V2, bool locked) { + const Constant *V2) { if (const ConstantInt *CB = dyn_cast(Cond)) return const_cast(CB->getZExtValue() ? V1 : V2); @@ -570,22 +566,21 @@ static Constant *EvalVectorOp(const ConstantVector *V1, const ConstantVector *V2, const VectorType *VTy, - Constant *(*FP)(Constant*, Constant*, bool)) { + Constant *(*FP)(Constant*, Constant*)) { std::vector Res; const Type *EltTy = VTy->getElementType(); for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { const Constant *C1 = V1 ? V1->getOperand(i) : Constant::getNullValue(EltTy); const Constant *C2 = V2 ? V2->getOperand(i) : Constant::getNullValue(EltTy); Res.push_back(FP(const_cast(C1), - const_cast(C2), true)); + const_cast(C2))); } return ConstantVector::get(Res); } Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *C1, - const Constant *C2, - bool locked) { + const Constant *C2) { // No compile-time operations on this type yet. if (C1->getType() == Type::PPC_FP128Ty) return 0; @@ -597,29 +592,29 @@ if (isa(C1) && isa(C2)) // Handle undef ^ undef -> 0 special case. This is a common // idiom (misuse). - return Constant::getNullValue(C1->getType(), locked); + return Constant::getNullValue(C1->getType()); // Fallthrough case Instruction::Add: case Instruction::Sub: - return UndefValue::get(C1->getType(), locked); + return UndefValue::get(C1->getType()); case Instruction::Mul: case Instruction::And: - return Constant::getNullValue(C1->getType(), locked); + return Constant::getNullValue(C1->getType()); case Instruction::UDiv: case Instruction::SDiv: case Instruction::URem: case Instruction::SRem: if (!isa(C2)) // undef / X -> 0 - return Constant::getNullValue(C1->getType(), locked); + return Constant::getNullValue(C1->getType()); return const_cast(C2); // X / undef -> undef case Instruction::Or: // X | undef -> -1 if (const VectorType *PTy = dyn_cast(C1->getType())) - return ConstantVector::getAllOnesValue(PTy, locked); - return ConstantInt::getAllOnesValue(C1->getType(), locked); + return ConstantVector::getAllOnesValue(PTy); + return ConstantInt::getAllOnesValue(C1->getType()); case Instruction::LShr: if (isa(C2) && isa(C1)) return const_cast(C1); // undef lshr undef -> undef - return Constant::getNullValue(C1->getType(), locked); // X lshr undef -> 0 + return Constant::getNullValue(C1->getType()); // X lshr undef -> 0 // undef lshr X -> 0 case Instruction::AShr: if (!isa(C2)) @@ -630,7 +625,7 @@ return const_cast(C1); // X ashr undef --> X case Instruction::Shl: // undef << X -> 0 or X << undef -> 0 - return Constant::getNullValue(C1->getType(), locked); + return Constant::getNullValue(C1->getType()); } } @@ -1577,7 +1572,7 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, Constant* const *Idxs, - unsigned NumIdx, bool locked) { + unsigned NumIdx) { if (NumIdx == 0 || (NumIdx == 1 && Idxs[0]->isNullValue())) return const_cast(C); @@ -1588,8 +1583,7 @@ (Value **)Idxs, (Value **)Idxs+NumIdx); assert(Ty != 0 && "Invalid indices for GEP!"); - return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace()), - locked); + return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace())); } Constant *Idx0 = Idxs[0]; @@ -1607,8 +1601,7 @@ (Value**)Idxs+NumIdx); assert(Ty != 0 && "Invalid indices for GEP!"); return - ConstantPointerNull::get(PointerType::get(Ty,Ptr->getAddressSpace()), - locked); + ConstantPointerNull::get(PointerType::get(Ty,Ptr->getAddressSpace())); } } @@ -1636,22 +1629,20 @@ if (!Idx0->isNullValue()) { const Type *IdxTy = Combined->getType(); if (IdxTy != Idx0->getType()) { - Constant *C1 = ConstantExpr::getSExtOrBitCast(Idx0, Type::Int64Ty, - locked); + Constant *C1 = ConstantExpr::getSExtOrBitCast(Idx0, Type::Int64Ty); Constant *C2 = ConstantExpr::getSExtOrBitCast(Combined, - Type::Int64Ty, - locked); - Combined = ConstantExpr::get(Instruction::Add, C1, C2, locked); + Type::Int64Ty); + Combined = ConstantExpr::get(Instruction::Add, C1, C2); } else { Combined = - ConstantExpr::get(Instruction::Add, Idx0, Combined, locked); + ConstantExpr::get(Instruction::Add, Idx0, Combined); } } NewIndices.push_back(Combined); NewIndices.insert(NewIndices.end(), Idxs+1, Idxs+NumIdx); return ConstantExpr::getGetElementPtr(CE->getOperand(0), &NewIndices[0], - NewIndices.size(), locked); + NewIndices.size()); } } @@ -1668,7 +1659,7 @@ dyn_cast(cast(C->getType())->getElementType())) if (CAT->getElementType() == SAT->getElementType()) return ConstantExpr::getGetElementPtr( - (Constant*)CE->getOperand(0), Idxs, NumIdx, locked); + (Constant*)CE->getOperand(0), Idxs, NumIdx); } // Fold: getelementptr (i8* inttoptr (i64 1 to i8*), i32 -1) @@ -1686,10 +1677,10 @@ Offset = ConstantExpr::getSExt(Offset, Base->getType()); else if (Base->getType()->getPrimitiveSizeInBits() < Offset->getType()->getPrimitiveSizeInBits()) - Base = ConstantExpr::getZExt(Base, Offset->getType(), locked); + Base = ConstantExpr::getZExt(Base, Offset->getType()); - Base = ConstantExpr::getAdd(Base, Offset, locked); - return ConstantExpr::getIntToPtr(Base, CE->getType(), locked); + Base = ConstantExpr::getAdd(Base, Offset); + return ConstantExpr::getIntToPtr(Base, CE->getType()); } } return 0; Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=73801&r1=73800&r2=73801&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Fri Jun 19 19:24:58 2009 @@ -25,6 +25,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MathExtras.h" +#include "llvm/System/Mutex.h" #include "llvm/System/RWMutex.h" #include "llvm/System/Threading.h" #include "llvm/ADT/DenseMap.h" @@ -127,27 +128,27 @@ } // Static constructor to create a '0' constant of arbitrary type... -Constant *Constant::getNullValue(const Type *Ty, bool locked) { +Constant *Constant::getNullValue(const Type *Ty) { static uint64_t zero[2] = {0, 0}; switch (Ty->getTypeID()) { case Type::IntegerTyID: - return ConstantInt::get(Ty, 0, locked); + return ConstantInt::get(Ty, 0); case Type::FloatTyID: - return ConstantFP::get(APFloat(APInt(32, 0)), locked); + return ConstantFP::get(APFloat(APInt(32, 0))); case Type::DoubleTyID: - return ConstantFP::get(APFloat(APInt(64, 0)), locked); + return ConstantFP::get(APFloat(APInt(64, 0))); case Type::X86_FP80TyID: - return ConstantFP::get(APFloat(APInt(80, 2, zero)), locked); + return ConstantFP::get(APFloat(APInt(80, 2, zero))); case Type::FP128TyID: - return ConstantFP::get(APFloat(APInt(128, 2, zero), true), locked); + return ConstantFP::get(APFloat(APInt(128, 2, zero), true)); case Type::PPC_FP128TyID: - return ConstantFP::get(APFloat(APInt(128, 2, zero)), locked); + return ConstantFP::get(APFloat(APInt(128, 2, zero))); case Type::PointerTyID: - return ConstantPointerNull::get(cast(Ty), locked); + return ConstantPointerNull::get(cast(Ty)); case Type::StructTyID: case Type::ArrayTyID: case Type::VectorTyID: - return ConstantAggregateZero::get(Ty, locked); + return ConstantAggregateZero::get(Ty); default: // Function, Label, or Opaque type? assert(!"Cannot create a null constant of that type!"); @@ -162,22 +163,21 @@ } // Static constructor to create an integral constant with all bits set -ConstantInt *ConstantInt::getAllOnesValue(const Type *Ty, bool locked) { +ConstantInt *ConstantInt::getAllOnesValue(const Type *Ty) { if (const IntegerType* ITy = dyn_cast(Ty)) - return ConstantInt::get(APInt::getAllOnesValue(ITy->getBitWidth()), locked); + return ConstantInt::get(APInt::getAllOnesValue(ITy->getBitWidth())); return 0; } /// @returns the value for a vector integer constant of the given type that /// has all its bits set to true. /// @brief Get the all ones value -ConstantVector *ConstantVector::getAllOnesValue(const VectorType *Ty, - bool locked) { +ConstantVector *ConstantVector::getAllOnesValue(const VectorType *Ty) { std::vector Elts; Elts.resize(Ty->getNumElements(), - ConstantInt::getAllOnesValue(Ty->getElementType(), locked)); + ConstantInt::getAllOnesValue(Ty->getElementType())); assert(Elts[0] && "Not a vector integer type!"); - return cast(ConstantVector::get(Elts, locked)); + return cast(ConstantVector::get(Elts)); } @@ -276,19 +276,17 @@ static ManagedStatic IntConstants; ConstantInt *ConstantInt::get(const IntegerType *Ty, - uint64_t V, bool isSigned, bool locked) { - return get(APInt(Ty->getBitWidth(), V, isSigned), locked); + uint64_t V, bool isSigned) { + return get(APInt(Ty->getBitWidth(), V, isSigned)); } -Constant *ConstantInt::get(const Type *Ty, uint64_t V, - bool isSigned, bool locked) { +Constant *ConstantInt::get(const Type *Ty, uint64_t V, bool isSigned) { Constant *C = get(cast(Ty->getScalarType()), V, isSigned); // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast(Ty)) return - ConstantVector::get(std::vector(VTy->getNumElements(), C), - locked); + ConstantVector::get(std::vector(VTy->getNumElements(), C)); return C; } @@ -298,42 +296,38 @@ // operator== and operator!= to ensure that the DenseMap doesn't attempt to // compare APInt's of different widths, which would violate an APInt class // invariant which generates an assertion. -ConstantInt *ConstantInt::get(const APInt& V, bool locked) { +ConstantInt *ConstantInt::get(const APInt& V) { // Get the corresponding integer type for the bit width of the value. const IntegerType *ITy = IntegerType::get(V.getBitWidth()); // get an existing value or the insertion position DenseMapAPIntKeyInfo::KeyTy Key(V, ITy); - if (locked) ConstantsLock->reader_acquire(); + ConstantsLock->reader_acquire(); ConstantInt *&Slot = (*IntConstants)[Key]; - if (locked) ConstantsLock->reader_release(); + ConstantsLock->reader_release(); if (!Slot) { - if (locked) { - sys::SmartScopedWriter Writer(&*ConstantsLock); - ConstantInt *&NewSlot = (*IntConstants)[Key]; - if (!Slot) { - NewSlot = new ConstantInt(ITy, V); - } - return NewSlot; - } else { - Slot = new ConstantInt(ITy, V); + sys::SmartScopedWriter Writer(&*ConstantsLock); + ConstantInt *&NewSlot = (*IntConstants)[Key]; + if (!Slot) { + NewSlot = new ConstantInt(ITy, V); } + + return NewSlot; + } else { + return Slot; } - - return Slot; } -Constant *ConstantInt::get(const Type *Ty, const APInt &V, bool locked) { - ConstantInt *C = ConstantInt::get(V, locked); +Constant *ConstantInt::get(const Type *Ty, const APInt &V) { + ConstantInt *C = ConstantInt::get(V); assert(C->getType() == Ty->getScalarType() && "ConstantInt type doesn't match the type implied by its value!"); // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast(Ty)) return - ConstantVector::get(std::vector(VTy->getNumElements(), C), - locked); + ConstantVector::get(std::vector(VTy->getNumElements(), C)); return C; } @@ -412,37 +406,17 @@ static ManagedStatic FPConstants; -ConstantFP *ConstantFP::get(const APFloat &V, bool locked) { +ConstantFP *ConstantFP::get(const APFloat &V) { DenseMapAPFloatKeyInfo::KeyTy Key(V); - if (locked) ConstantsLock->reader_acquire(); + ConstantsLock->reader_acquire(); ConstantFP *&Slot = (*FPConstants)[Key]; - if (locked) ConstantsLock->reader_release(); + ConstantsLock->reader_release(); if (!Slot) { - if (locked) { - sys::SmartScopedWriter Writer(&*ConstantsLock); - ConstantFP *&NewSlot = (*FPConstants)[Key]; - if (!NewSlot) { - const Type *Ty; - if (&V.getSemantics() == &APFloat::IEEEsingle) - Ty = Type::FloatTy; - else if (&V.getSemantics() == &APFloat::IEEEdouble) - Ty = Type::DoubleTy; - else if (&V.getSemantics() == &APFloat::x87DoubleExtended) - Ty = Type::X86_FP80Ty; - else if (&V.getSemantics() == &APFloat::IEEEquad) - Ty = Type::FP128Ty; - else { - assert(&V.getSemantics() == &APFloat::PPCDoubleDouble && - "Unknown FP format"); - Ty = Type::PPC_FP128Ty; - } - NewSlot = new ConstantFP(Ty, V); - } - - return NewSlot; - } else { + sys::SmartScopedWriter Writer(&*ConstantsLock); + ConstantFP *&NewSlot = (*FPConstants)[Key]; + if (!NewSlot) { const Type *Ty; if (&V.getSemantics() == &APFloat::IEEEsingle) Ty = Type::FloatTy; @@ -457,8 +431,10 @@ "Unknown FP format"); Ty = Type::PPC_FP128Ty; } - Slot = new ConstantFP(Ty, V); + NewSlot = new ConstantFP(Ty, V); } + + return NewSlot; } return Slot; @@ -467,18 +443,17 @@ /// get() - This returns a constant fp for the specified value in the /// specified type. This should only be used for simple constant values like /// 2.0/1.0 etc, that are known-valid both as double and as the target format. -Constant *ConstantFP::get(const Type *Ty, double V, bool locked) { +Constant *ConstantFP::get(const Type *Ty, double V) { APFloat FV(V); bool ignored; FV.convert(*TypeToFloatSemantics(Ty->getScalarType()), APFloat::rmNearestTiesToEven, &ignored); - Constant *C = get(FV, locked); + Constant *C = get(FV); // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast(Ty)) return - ConstantVector::get(std::vector(VTy->getNumElements(), C), - locked); + ConstantVector::get(std::vector(VTy->getNumElements(), C)); return C; } @@ -882,50 +857,50 @@ return get(Instruction::Xor, C, Constant::getAllOnesValue(C->getType())); } -Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::Add, C1, C2, locked); +Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2) { + return get(Instruction::Add, C1, C2); } -Constant *ConstantExpr::getFAdd(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::FAdd, C1, C2, locked); +Constant *ConstantExpr::getFAdd(Constant *C1, Constant *C2) { + return get(Instruction::FAdd, C1, C2); } -Constant *ConstantExpr::getSub(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::Sub, C1, C2, locked); +Constant *ConstantExpr::getSub(Constant *C1, Constant *C2) { + return get(Instruction::Sub, C1, C2); } -Constant *ConstantExpr::getFSub(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::FSub, C1, C2, locked); +Constant *ConstantExpr::getFSub(Constant *C1, Constant *C2) { + return get(Instruction::FSub, C1, C2); } -Constant *ConstantExpr::getMul(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::Mul, C1, C2, locked); +Constant *ConstantExpr::getMul(Constant *C1, Constant *C2) { + return get(Instruction::Mul, C1, C2); } -Constant *ConstantExpr::getFMul(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::FMul, C1, C2, locked); +Constant *ConstantExpr::getFMul(Constant *C1, Constant *C2) { + return get(Instruction::FMul, C1, C2); } -Constant *ConstantExpr::getUDiv(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::UDiv, C1, C2, locked); +Constant *ConstantExpr::getUDiv(Constant *C1, Constant *C2) { + return get(Instruction::UDiv, C1, C2); } -Constant *ConstantExpr::getSDiv(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::SDiv, C1, C2, locked); +Constant *ConstantExpr::getSDiv(Constant *C1, Constant *C2) { + return get(Instruction::SDiv, C1, C2); } -Constant *ConstantExpr::getFDiv(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::FDiv, C1, C2, locked); +Constant *ConstantExpr::getFDiv(Constant *C1, Constant *C2) { + return get(Instruction::FDiv, C1, C2); } -Constant *ConstantExpr::getURem(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::URem, C1, C2, locked); +Constant *ConstantExpr::getURem(Constant *C1, Constant *C2) { + return get(Instruction::URem, C1, C2); } -Constant *ConstantExpr::getSRem(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::SRem, C1, C2, locked); +Constant *ConstantExpr::getSRem(Constant *C1, Constant *C2) { + return get(Instruction::SRem, C1, C2); } -Constant *ConstantExpr::getFRem(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::FRem, C1, C2, locked); +Constant *ConstantExpr::getFRem(Constant *C1, Constant *C2) { + return get(Instruction::FRem, C1, C2); } -Constant *ConstantExpr::getAnd(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::And, C1, C2, locked); +Constant *ConstantExpr::getAnd(Constant *C1, Constant *C2) { + return get(Instruction::And, C1, C2); } -Constant *ConstantExpr::getOr(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::Or, C1, C2, locked); +Constant *ConstantExpr::getOr(Constant *C1, Constant *C2) { + return get(Instruction::Or, C1, C2); } -Constant *ConstantExpr::getXor(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::Xor, C1, C2, locked); +Constant *ConstantExpr::getXor(Constant *C1, Constant *C2) { + return get(Instruction::Xor, C1, C2); } unsigned ConstantExpr::getPredicate() const { assert(getOpcode() == Instruction::FCmp || @@ -934,14 +909,14 @@ getOpcode() == Instruction::VICmp); return ((const CompareConstantExpr*)this)->predicate; } -Constant *ConstantExpr::getShl(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::Shl, C1, C2, locked); +Constant *ConstantExpr::getShl(Constant *C1, Constant *C2) { + return get(Instruction::Shl, C1, C2); } -Constant *ConstantExpr::getLShr(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::LShr, C1, C2, locked); +Constant *ConstantExpr::getLShr(Constant *C1, Constant *C2) { + return get(Instruction::LShr, C1, C2); } -Constant *ConstantExpr::getAShr(Constant *C1, Constant *C2, bool locked) { - return get(Instruction::AShr, C1, C2, locked); +Constant *ConstantExpr::getAShr(Constant *C1, Constant *C2) { + return get(Instruction::AShr, C1, C2); } /// getWithOperandReplaced - Return a constant expression identical to this @@ -1178,6 +1153,9 @@ /// AbstractTypeMap - Map for abstract type constants. /// AbstractTypeMapTy AbstractTypeMap; + + /// ValueMapLock - Mutex for this map. + sys::SmartMutex ValueMapLock; public: // NOTE: This function is not locked. It is the caller's responsibility @@ -1253,36 +1231,7 @@ /// getOrCreate - Return the specified constant from the map, creating it if /// necessary. ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { - MapKey Lookup(Ty, V); - ConstantClass* Result = 0; - - ConstantsLock->reader_acquire(); - typename MapTy::iterator I = Map.find(Lookup); - // Is it in the map? - if (I != Map.end()) - Result = static_cast(I->second); - ConstantsLock->reader_release(); - - if (!Result) { - sys::SmartScopedWriter Writer(&*ConstantsLock); - I = Map.find(Lookup); - // Is it in the map? - if (I != Map.end()) - Result = static_cast(I->second); - if (!Result) { - // If no preexisting value, create one now... - Result = Create(Ty, V, I); - } - } - - return Result; - } - - /// unlockedGetOrCreate - Return the specified constant from the map, - /// creating it if necessary. This version performs no locking, and should - /// only be used during recursive type refinement, when the locks are - /// already held. - ConstantClass *unlockedGetOrCreate(const TypeClass *Ty, const ValType &V) { + sys::SmartScopedLock Lock(&ValueMapLock); MapKey Lookup(Ty, V); ConstantClass* Result = 0; @@ -1299,8 +1248,8 @@ return Result; } - void remove(ConstantClass *CP, bool locked = true) { - if (locked) ConstantsLock->writer_acquire(); + void remove(ConstantClass *CP) { + sys::SmartScopedLock Lock(&ValueMapLock); typename MapTy::iterator I = FindExistingElement(CP); assert(I != Map.end() && "Constant not found in constant table!"); assert(I->second == CP && "Didn't find correct element?"); @@ -1348,8 +1297,6 @@ } Map.erase(I); - - if (locked) ConstantsLock->writer_release(); } @@ -1387,7 +1334,7 @@ } void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) { - ConstantsLock->writer_acquire(); + sys::SmartScopedLock Lock(&ValueMapLock); typename AbstractTypeMapTy::iterator I = AbstractTypeMap.find(cast(OldTy)); @@ -1405,14 +1352,11 @@ I = AbstractTypeMap.find(cast(OldTy)); } while (I != AbstractTypeMap.end()); - - ConstantsLock->writer_release(); } // If the type became concrete without being refined to any other existing // type, we just remove ourselves from the ATU list. void typeBecameConcrete(const DerivedType *AbsTy) { - sys::SmartScopedWriter Writer(&*ConstantsLock); AbsTy->removeAbstractTypeUser(this); } @@ -1439,10 +1383,10 @@ struct ConvertConstantType { static void convert(ConstantAggregateZero *OldC, const Type *NewTy) { // Make everyone now use a constant of the new type... - Constant *New = ConstantAggregateZero::get(NewTy, false); + Constant *New = ConstantAggregateZero::get(NewTy); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(false); // This constant is now dead, destroy it. + OldC->destroyConstant(); // This constant is now dead, destroy it. } }; } @@ -1452,19 +1396,19 @@ static char getValType(ConstantAggregateZero *CPZ) { return 0; } -ConstantAggregateZero *ConstantAggregateZero::get(const Type *Ty, bool locked) { +ConstantAggregateZero *ConstantAggregateZero::get(const Type *Ty) { assert((isa(Ty) || isa(Ty) || isa(Ty)) && "Cannot create an aggregate zero of non-aggregate type!"); - - return locked ? AggZeroConstants->getOrCreate(Ty, 0) : - AggZeroConstants->unlockedGetOrCreate(Ty, 0); + + // Implicitly locked. + return AggZeroConstants->getOrCreate(Ty, 0); } /// destroyConstant - Remove the constant from the constant table... /// -void ConstantAggregateZero::destroyConstant(bool locked) { +void ConstantAggregateZero::destroyConstant() { // Implicitly locked. - AggZeroConstants->remove(this, locked); + AggZeroConstants->remove(this); destroyConstantImpl(); } @@ -1478,10 +1422,10 @@ std::vector C; for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) C.push_back(cast(OldC->getOperand(i))); - Constant *New = ConstantArray::get(NewTy, C, false); + Constant *New = ConstantArray::get(NewTy, C); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(false); // This constant is now dead, destroy it. + OldC->destroyConstant(); // This constant is now dead, destroy it. } }; } @@ -1499,36 +1443,29 @@ static ManagedStatic ArrayConstants; Constant *ConstantArray::get(const ArrayType *Ty, - const std::vector &V, - bool locked) { + const std::vector &V) { // If this is an all-zero array, return a ConstantAggregateZero object if (!V.empty()) { Constant *C = V[0]; if (!C->isNullValue()) { - if (locked) - // Implicitly locked. - return ArrayConstants->getOrCreate(Ty, V); - else - return ArrayConstants->unlockedGetOrCreate(Ty, V); + // Implicitly locked. + return ArrayConstants->getOrCreate(Ty, V); } for (unsigned i = 1, e = V.size(); i != e; ++i) if (V[i] != C) { - if (locked) - // Implicitly locked. - return ArrayConstants->getOrCreate(Ty, V); - else - return ArrayConstants->unlockedGetOrCreate(Ty, V); + // Implicitly locked. + return ArrayConstants->getOrCreate(Ty, V); } } - return ConstantAggregateZero::get(Ty, locked); + return ConstantAggregateZero::get(Ty); } /// destroyConstant - Remove the constant from the constant table... /// -void ConstantArray::destroyConstant(bool locked) { +void ConstantArray::destroyConstant() { // Implicitly locked. - ArrayConstants->remove(this, locked); + ArrayConstants->remove(this); destroyConstantImpl(); } @@ -1538,8 +1475,7 @@ /// Otherwise, the length parameter specifies how much of the string to use /// and it won't be null terminated. /// -Constant *ConstantArray::get(const std::string &Str, - bool AddNull, bool locked) { +Constant *ConstantArray::get(const std::string &Str, bool AddNull) { std::vector ElementVals; for (unsigned i = 0; i < Str.length(); ++i) ElementVals.push_back(ConstantInt::get(Type::Int8Ty, Str[i])); @@ -1550,7 +1486,7 @@ } ArrayType *ATy = ArrayType::get(Type::Int8Ty, ElementVals.size()); - return ConstantArray::get(ATy, ElementVals, locked); + return ConstantArray::get(ATy, ElementVals); } /// isString - This method returns true if the array is an array of i8, and @@ -1614,11 +1550,11 @@ std::vector C; for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) C.push_back(cast(OldC->getOperand(i))); - Constant *New = ConstantStruct::get(NewTy, C, false); + Constant *New = ConstantStruct::get(NewTy, C); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(false); // This constant is now dead, destroy it. + OldC->destroyConstant(); // This constant is now dead, destroy it. } }; } @@ -1636,31 +1572,29 @@ } Constant *ConstantStruct::get(const StructType *Ty, - const std::vector &V, - bool locked) { + const std::vector &V) { // Create a ConstantAggregateZero value if all elements are zeros... for (unsigned i = 0, e = V.size(); i != e; ++i) if (!V[i]->isNullValue()) - return locked ? StructConstants->getOrCreate(Ty, V) : - StructConstants->unlockedGetOrCreate(Ty, V); + // Implicitly locked. + return StructConstants->getOrCreate(Ty, V); - return ConstantAggregateZero::get(Ty, locked); + return ConstantAggregateZero::get(Ty); } -Constant *ConstantStruct::get(const std::vector &V, bool packed, - bool locked) { +Constant *ConstantStruct::get(const std::vector &V, bool packed) { std::vector StructEls; StructEls.reserve(V.size()); for (unsigned i = 0, e = V.size(); i != e; ++i) StructEls.push_back(V[i]->getType()); - return get(StructType::get(StructEls, packed), V, locked); + return get(StructType::get(StructEls, packed), V); } // destroyConstant - Remove the constant from the constant table... // -void ConstantStruct::destroyConstant(bool locked) { +void ConstantStruct::destroyConstant() { // Implicitly locked. - StructConstants->remove(this, locked); + StructConstants->remove(this); destroyConstantImpl(); } @@ -1674,10 +1608,10 @@ std::vector C; for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) C.push_back(cast(OldC->getOperand(i))); - Constant *New = ConstantVector::get(NewTy, C, false); + Constant *New = ConstantVector::get(NewTy, C); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(false); // This constant is now dead, destroy it. + OldC->destroyConstant(); // This constant is now dead, destroy it. } }; } @@ -1694,8 +1628,7 @@ ConstantVector> > VectorConstants; Constant *ConstantVector::get(const VectorType *Ty, - const std::vector &V, - bool locked) { + const std::vector &V) { assert(!V.empty() && "Vectors can't be empty"); // If this is an all-undef or alll-zero vector, return a // ConstantAggregateZero or UndefValue. @@ -1712,24 +1645,24 @@ } if (isZero) - return ConstantAggregateZero::get(Ty, locked); + return ConstantAggregateZero::get(Ty); if (isUndef) - return UndefValue::get(Ty, locked); + return UndefValue::get(Ty); - return locked ? VectorConstants->getOrCreate(Ty, V) : - VectorConstants->unlockedGetOrCreate(Ty, V); + // Implicitly locked. + return VectorConstants->getOrCreate(Ty, V); } -Constant *ConstantVector::get(const std::vector &V, bool locked) { +Constant *ConstantVector::get(const std::vector &V) { assert(!V.empty() && "Cannot infer type if V is empty"); - return get(VectorType::get(V.front()->getType(),V.size()), V, locked); + return get(VectorType::get(V.front()->getType(),V.size()), V); } // destroyConstant - Remove the constant from the constant table... // -void ConstantVector::destroyConstant(bool locked) { +void ConstantVector::destroyConstant() { // Implicitly locked. - VectorConstants->remove(this, locked); + VectorConstants->remove(this); destroyConstantImpl(); } @@ -1776,10 +1709,10 @@ struct ConvertConstantType { static void convert(ConstantPointerNull *OldC, const PointerType *NewTy) { // Make everyone now use a constant of the new type... - Constant *New = ConstantPointerNull::get(NewTy, false); + Constant *New = ConstantPointerNull::get(NewTy); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(false); // This constant is now dead, destroy it. + OldC->destroyConstant(); // This constant is now dead, destroy it. } }; } @@ -1792,18 +1725,16 @@ } -ConstantPointerNull *ConstantPointerNull::get(const PointerType *Ty, - bool locked) { +ConstantPointerNull *ConstantPointerNull::get(const PointerType *Ty) { // Implicitly locked. - return locked ? NullPtrConstants->getOrCreate(Ty, 0) : - NullPtrConstants->unlockedGetOrCreate(Ty, 0); + return NullPtrConstants->getOrCreate(Ty, 0); } // destroyConstant - Remove the constant from the constant table... // -void ConstantPointerNull::destroyConstant(bool locked) { +void ConstantPointerNull::destroyConstant() { // Implicitly locked. - NullPtrConstants->remove(this, locked); + NullPtrConstants->remove(this); destroyConstantImpl(); } @@ -1824,10 +1755,10 @@ struct ConvertConstantType { static void convert(UndefValue *OldC, const Type *NewTy) { // Make everyone now use a constant of the new type. - Constant *New = UndefValue::get(NewTy, false); + Constant *New = UndefValue::get(NewTy); assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(false); // This constant is now dead, destroy it. + OldC->destroyConstant(); // This constant is now dead, destroy it. } }; } @@ -1839,16 +1770,16 @@ } -UndefValue *UndefValue::get(const Type *Ty, bool locked) { - return locked ? UndefValueConstants->getOrCreate(Ty, 0) : - UndefValueConstants->unlockedGetOrCreate(Ty, 0); +UndefValue *UndefValue::get(const Type *Ty) { + // Implicitly locked. + return UndefValueConstants->getOrCreate(Ty, 0); } // destroyConstant - Remove the constant from the constant table. // -void UndefValue::destroyConstant(bool locked) { +void UndefValue::destroyConstant() { // Implicitly locked. - UndefValueConstants->remove(this, locked); + UndefValueConstants->remove(this); destroyConstantImpl(); } @@ -1861,25 +1792,21 @@ static ManagedStatic > MDStringCache; -MDString *MDString::get(const char *StrBegin, const char *StrEnd, bool locked) { - if (locked) ConstantsLock->writer_acquire(); - +MDString *MDString::get(const char *StrBegin, const char *StrEnd) { + sys::SmartScopedWriter Writer(&*ConstantsLock); StringMapEntry &Entry = MDStringCache->GetOrCreateValue( StrBegin, StrEnd); MDString *&S = Entry.getValue(); if (!S) S = new MDString(Entry.getKeyData(), Entry.getKeyData() + Entry.getKeyLength()); - if (locked) ConstantsLock->writer_release(); - return S; } -void MDString::destroyConstant(bool locked) { - if (locked) ConstantsLock->writer_acquire(); +void MDString::destroyConstant() { + sys::SmartScopedWriter Writer(&*ConstantsLock); MDStringCache->erase(MDStringCache->find(StrBegin, StrEnd)); destroyConstantImpl(); - if (locked) ConstantsLock->writer_release(); } //---- MDNode::get() implementation @@ -1898,26 +1825,20 @@ ID.AddPointer(*I); } -MDNode *MDNode::get(Value*const* Vals, unsigned NumVals, bool locked) { +MDNode *MDNode::get(Value*const* Vals, unsigned NumVals) { FoldingSetNodeID ID; for (unsigned i = 0; i != NumVals; ++i) ID.AddPointer(Vals[i]); - if (locked) ConstantsLock->reader_acquire(); + ConstantsLock->reader_acquire(); void *InsertPoint; MDNode *N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); - if (locked) ConstantsLock->reader_release(); + ConstantsLock->reader_release(); if (!N) { - if (locked) { - sys::SmartScopedWriter Writer(&*ConstantsLock); - N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); - if (!N) { - // InsertPoint will have been set by the FindNodeOrInsertPos call. - N = new(0) MDNode(Vals, NumVals); - MDNodeSet->InsertNode(N, InsertPoint); - } - } else { + sys::SmartScopedWriter Writer(&*ConstantsLock); + N = MDNodeSet->FindNodeOrInsertPos(ID, InsertPoint); + if (!N) { // InsertPoint will have been set by the FindNodeOrInsertPos call. N = new(0) MDNode(Vals, NumVals); MDNodeSet->InsertNode(N, InsertPoint); @@ -1926,11 +1847,11 @@ return N; } -void MDNode::destroyConstant(bool locked) { - if (locked) ConstantsLock->writer_acquire(); +void MDNode::destroyConstant() { + sys::SmartScopedWriter Writer(&*ConstantsLock); MDNodeSet->RemoveNode(this); + destroyConstantImpl(); - if (locked) ConstantsLock->writer_release(); } //---- ConstantExpr::get() implementations... @@ -2041,30 +1962,30 @@ case Instruction::IntToPtr: case Instruction::BitCast: New = ConstantExpr::getCast(OldC->getOpcode(), OldC->getOperand(0), - NewTy, false); + NewTy); break; case Instruction::Select: New = ConstantExpr::getSelectTy(NewTy, OldC->getOperand(0), OldC->getOperand(1), - OldC->getOperand(2), false); + OldC->getOperand(2)); break; default: assert(OldC->getOpcode() >= Instruction::BinaryOpsBegin && OldC->getOpcode() < Instruction::BinaryOpsEnd); New = ConstantExpr::getTy(NewTy, OldC->getOpcode(), OldC->getOperand(0), - OldC->getOperand(1), false); + OldC->getOperand(1)); break; case Instruction::GetElementPtr: // Make everyone now use a constant of the new type... std::vector Idx(OldC->op_begin()+1, OldC->op_end()); New = ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0), - &Idx[0], Idx.size(), false); + &Idx[0], Idx.size()); break; } assert(New != OldC && "Didn't replace constant??"); OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(false); // This constant is now dead, destroy it. + OldC->destroyConstant(); // This constant is now dead, destroy it. } }; } // end namespace llvm @@ -2087,10 +2008,10 @@ /// This is a utility function to handle folding of casts and lookup of the /// cast in the ExprConstants map. It is used by the various get* methods below. static inline Constant *getFoldedCast( - Instruction::CastOps opc, Constant *C, const Type *Ty, bool locked) { + Instruction::CastOps opc, Constant *C, const Type *Ty) { assert(Ty->isFirstClassType() && "Cannot cast to an aggregate type!"); // Fold a few common cases - if (Constant *FC = ConstantFoldCastInstruction(opc, C, Ty, locked)) + if (Constant *FC = ConstantFoldCastInstruction(opc, C, Ty)) return FC; // Look up the constant in the table first to ensure uniqueness @@ -2098,12 +2019,10 @@ ExprMapKeyType Key(opc, argVec); // Implicitly locked. - return locked ? ExprConstants->getOrCreate(Ty, Key) : - ExprConstants->unlockedGetOrCreate(Ty, Key); + return ExprConstants->getOrCreate(Ty, Key); } -Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty, - bool locked) { +Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty) { Instruction::CastOps opc = Instruction::CastOps(oc); assert(Instruction::isCast(opc) && "opcode out of range"); assert(C && Ty && "Null arguments to getCast"); @@ -2113,18 +2032,18 @@ default: assert(0 && "Invalid cast opcode"); break; - case Instruction::Trunc: return getTrunc(C, Ty, locked); - case Instruction::ZExt: return getZExt(C, Ty, locked); - case Instruction::SExt: return getSExt(C, Ty, locked); - case Instruction::FPTrunc: return getFPTrunc(C, Ty, locked); - case Instruction::FPExt: return getFPExtend(C, Ty, locked); - case Instruction::UIToFP: return getUIToFP(C, Ty, locked); - case Instruction::SIToFP: return getSIToFP(C, Ty, locked); - case Instruction::FPToUI: return getFPToUI(C, Ty, locked); - case Instruction::FPToSI: return getFPToSI(C, Ty, locked); - case Instruction::PtrToInt: return getPtrToInt(C, Ty, locked); - case Instruction::IntToPtr: return getIntToPtr(C, Ty, locked); - case Instruction::BitCast: return getBitCast(C, Ty, locked); + case Instruction::Trunc: return getTrunc(C, Ty); + case Instruction::ZExt: return getZExt(C, Ty); + case Instruction::SExt: return getSExt(C, Ty); + case Instruction::FPTrunc: return getFPTrunc(C, Ty); + case Instruction::FPExt: return getFPExtend(C, Ty); + case Instruction::UIToFP: return getUIToFP(C, Ty); + case Instruction::SIToFP: return getSIToFP(C, Ty); + case Instruction::FPToUI: return getFPToUI(C, Ty); + case Instruction::FPToSI: return getFPToSI(C, Ty); + case Instruction::PtrToInt: return getPtrToInt(C, Ty); + case Instruction::IntToPtr: return getIntToPtr(C, Ty); + case Instruction::BitCast: return getBitCast(C, Ty); } return 0; } @@ -2135,11 +2054,10 @@ return getCast(Instruction::ZExt, C, Ty); } -Constant *ConstantExpr::getSExtOrBitCast(Constant *C, const Type *Ty, - bool locked) { +Constant *ConstantExpr::getSExtOrBitCast(Constant *C, const Type *Ty) { if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits()) - return getCast(Instruction::BitCast, C, Ty, locked); - return getCast(Instruction::SExt, C, Ty, locked); + return getCast(Instruction::BitCast, C, Ty); + return getCast(Instruction::SExt, C, Ty); } Constant *ConstantExpr::getTruncOrBitCast(Constant *C, const Type *Ty) { @@ -2148,14 +2066,13 @@ return getCast(Instruction::Trunc, C, Ty); } -Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty, - bool locked) { +Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) { assert(isa(S->getType()) && "Invalid cast"); assert((Ty->isInteger() || isa(Ty)) && "Invalid cast"); if (Ty->isInteger()) - return getCast(Instruction::PtrToInt, S, Ty, locked); - return getCast(Instruction::BitCast, S, Ty, locked); + return getCast(Instruction::PtrToInt, S, Ty); + return getCast(Instruction::BitCast, S, Ty); } Constant *ConstantExpr::getIntegerCast(Constant *C, const Type *Ty, @@ -2183,7 +2100,7 @@ return getCast(opcode, C, Ty); } -Constant *ConstantExpr::getTrunc(Constant *C, const Type *Ty, bool locked) { +Constant *ConstantExpr::getTrunc(Constant *C, const Type *Ty) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2194,10 +2111,10 @@ assert(C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& "SrcTy must be larger than DestTy for Trunc!"); - return getFoldedCast(Instruction::Trunc, C, Ty, locked); + return getFoldedCast(Instruction::Trunc, C, Ty); } -Constant *ConstantExpr::getSExt(Constant *C, const Type *Ty, bool locked) { +Constant *ConstantExpr::getSExt(Constant *C, const Type *Ty) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2208,10 +2125,10 @@ assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "SrcTy must be smaller than DestTy for SExt!"); - return getFoldedCast(Instruction::SExt, C, Ty, locked); + return getFoldedCast(Instruction::SExt, C, Ty); } -Constant *ConstantExpr::getZExt(Constant *C, const Type *Ty, bool locked) { +Constant *ConstantExpr::getZExt(Constant *C, const Type *Ty) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2222,10 +2139,10 @@ assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "SrcTy must be smaller than DestTy for ZExt!"); - return getFoldedCast(Instruction::ZExt, C, Ty, locked); + return getFoldedCast(Instruction::ZExt, C, Ty); } -Constant *ConstantExpr::getFPTrunc(Constant *C, const Type *Ty, bool locked) { +Constant *ConstantExpr::getFPTrunc(Constant *C, const Type *Ty) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2234,10 +2151,10 @@ assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& "This is an illegal floating point truncation!"); - return getFoldedCast(Instruction::FPTrunc, C, Ty, locked); + return getFoldedCast(Instruction::FPTrunc, C, Ty); } -Constant *ConstantExpr::getFPExtend(Constant *C, const Type *Ty, bool locked) { +Constant *ConstantExpr::getFPExtend(Constant *C, const Type *Ty) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2246,10 +2163,10 @@ assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() && C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& "This is an illegal floating point extension!"); - return getFoldedCast(Instruction::FPExt, C, Ty, locked); + return getFoldedCast(Instruction::FPExt, C, Ty); } -Constant *ConstantExpr::getUIToFP(Constant *C, const Type *Ty, bool locked) { +Constant *ConstantExpr::getUIToFP(Constant *C, const Type *Ty) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2257,10 +2174,10 @@ assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert(C->getType()->isIntOrIntVector() && Ty->isFPOrFPVector() && "This is an illegal uint to floating point cast!"); - return getFoldedCast(Instruction::UIToFP, C, Ty, locked); + return getFoldedCast(Instruction::UIToFP, C, Ty); } -Constant *ConstantExpr::getSIToFP(Constant *C, const Type *Ty, bool locked) { +Constant *ConstantExpr::getSIToFP(Constant *C, const Type *Ty) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2268,10 +2185,10 @@ assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert(C->getType()->isIntOrIntVector() && Ty->isFPOrFPVector() && "This is an illegal sint to floating point cast!"); - return getFoldedCast(Instruction::SIToFP, C, Ty, locked); + return getFoldedCast(Instruction::SIToFP, C, Ty); } -Constant *ConstantExpr::getFPToUI(Constant *C, const Type *Ty, bool locked) { +Constant *ConstantExpr::getFPToUI(Constant *C, const Type *Ty) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2279,10 +2196,10 @@ assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert(C->getType()->isFPOrFPVector() && Ty->isIntOrIntVector() && "This is an illegal floating point to uint cast!"); - return getFoldedCast(Instruction::FPToUI, C, Ty, locked); + return getFoldedCast(Instruction::FPToUI, C, Ty); } -Constant *ConstantExpr::getFPToSI(Constant *C, const Type *Ty, bool locked) { +Constant *ConstantExpr::getFPToSI(Constant *C, const Type *Ty) { #ifndef NDEBUG bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; bool toVec = Ty->getTypeID() == Type::VectorTyID; @@ -2290,25 +2207,22 @@ assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); assert(C->getType()->isFPOrFPVector() && Ty->isIntOrIntVector() && "This is an illegal floating point to sint cast!"); - return getFoldedCast(Instruction::FPToSI, C, Ty, locked); + return getFoldedCast(Instruction::FPToSI, C, Ty); } -Constant *ConstantExpr::getPtrToInt(Constant *C, const Type *DstTy, - bool locked) { +Constant *ConstantExpr::getPtrToInt(Constant *C, const Type *DstTy) { assert(isa(C->getType()) && "PtrToInt source must be pointer"); assert(DstTy->isInteger() && "PtrToInt destination must be integral"); - return getFoldedCast(Instruction::PtrToInt, C, DstTy, locked); + return getFoldedCast(Instruction::PtrToInt, C, DstTy); } -Constant *ConstantExpr::getIntToPtr(Constant *C, const Type *DstTy, - bool locked) { +Constant *ConstantExpr::getIntToPtr(Constant *C, const Type *DstTy) { assert(C->getType()->isInteger() && "IntToPtr source must be integral"); assert(isa(DstTy) && "IntToPtr destination must be a pointer"); - return getFoldedCast(Instruction::IntToPtr, C, DstTy, locked); + return getFoldedCast(Instruction::IntToPtr, C, DstTy); } -Constant *ConstantExpr::getBitCast(Constant *C, const Type *DstTy, - bool locked) { +Constant *ConstantExpr::getBitCast(Constant *C, const Type *DstTy) { // BitCast implies a no-op cast of type only. No bits change. However, you // can't cast pointers to anything but pointers. #ifndef NDEBUG @@ -2328,7 +2242,7 @@ // speedily. if (C->getType() == DstTy) return C; - return getFoldedCast(Instruction::BitCast, C, DstTy, locked); + return getFoldedCast(Instruction::BitCast, C, DstTy); } Constant *ConstantExpr::getAlignOf(const Type *Ty) { @@ -2351,7 +2265,7 @@ } Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode, - Constant *C1, Constant *C2, bool locked) { + Constant *C1, Constant *C2) { // Check the operands for consistency first assert(Opcode >= Instruction::BinaryOpsBegin && Opcode < Instruction::BinaryOpsEnd && @@ -2360,14 +2274,14 @@ "Operand types in binary constant expression should match"); if (ReqTy == C1->getType() || ReqTy == Type::Int1Ty) - if (Constant *FC = ConstantFoldBinaryInstruction(Opcode, C1, C2, locked)) + if (Constant *FC = ConstantFoldBinaryInstruction(Opcode, C1, C2)) return FC; // Fold a few common cases... std::vector argVec(1, C1); argVec.push_back(C2); ExprMapKeyType Key(Opcode, argVec); - return locked ? ExprConstants->getOrCreate(ReqTy, Key) : - ExprConstants->unlockedGetOrCreate(ReqTy, Key); + // Implicitly locked. + return ExprConstants->getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getCompareTy(unsigned short predicate, @@ -2392,8 +2306,7 @@ } } -Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2, - bool locked) { +Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) { // API compatibility: Adjust integer opcodes to floating-point opcodes. if (C1->getType()->isFPOrFPVector()) { if (Opcode == Instruction::Add) Opcode = Instruction::FAdd; @@ -2458,7 +2371,7 @@ } #endif - return getTy(C1->getType(), Opcode, C1, C2, locked); + return getTy(C1->getType(), Opcode, C1, C2); } Constant *ConstantExpr::getCompare(unsigned short pred, @@ -2468,11 +2381,11 @@ } Constant *ConstantExpr::getSelectTy(const Type *ReqTy, Constant *C, - Constant *V1, Constant *V2, bool locked) { + Constant *V1, Constant *V2) { assert(!SelectInst::areInvalidOperands(C, V1, V2)&&"Invalid select operands"); if (ReqTy == V1->getType()) - if (Constant *SC = ConstantFoldSelectInstruction(C, V1, V2, locked)) + if (Constant *SC = ConstantFoldSelectInstruction(C, V1, V2)) return SC; // Fold common cases std::vector argVec(3, C); @@ -2480,20 +2393,19 @@ argVec[2] = V2; ExprMapKeyType Key(Instruction::Select, argVec); - return locked ? ExprConstants->getOrCreate(ReqTy, Key) : - ExprConstants->unlockedGetOrCreate(ReqTy, Key); + // Implicitly locked. + return ExprConstants->getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getGetElementPtrTy(const Type *ReqTy, Constant *C, Value* const *Idxs, - unsigned NumIdx, bool locked) { + unsigned NumIdx) { assert(GetElementPtrInst::getIndexedType(C->getType(), Idxs, Idxs+NumIdx) == cast(ReqTy)->getElementType() && "GEP indices invalid!"); - if (Constant *FC = ConstantFoldGetElementPtr(C, (Constant**)Idxs, - NumIdx, locked)) + if (Constant *FC = ConstantFoldGetElementPtr(C, (Constant**)Idxs, NumIdx)) return FC; // Fold a few common cases... assert(isa(C->getType()) && @@ -2507,24 +2419,22 @@ const ExprMapKeyType Key(Instruction::GetElementPtr, ArgVec); // Implicitly locked. - return locked ? ExprConstants->getOrCreate(ReqTy, Key) : - ExprConstants->unlockedGetOrCreate(ReqTy, Key); + return ExprConstants->getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getGetElementPtr(Constant *C, Value* const *Idxs, - unsigned NumIdx, bool locked) { + unsigned NumIdx) { // Get the result type of the getelementptr! const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(), Idxs, Idxs+NumIdx); assert(Ty && "GEP indices invalid!"); unsigned As = cast(C->getType())->getAddressSpace(); - return getGetElementPtrTy(PointerType::get(Ty, As), C, Idxs, - NumIdx, locked); + return getGetElementPtrTy(PointerType::get(Ty, As), C, Idxs, NumIdx); } Constant *ConstantExpr::getGetElementPtr(Constant *C, Constant* const *Idxs, - unsigned NumIdx, bool locked) { - return getGetElementPtr(C, (Value* const *)Idxs, NumIdx, locked); + unsigned NumIdx) { + return getGetElementPtr(C, (Value* const *)Idxs, NumIdx); } @@ -2803,8 +2713,9 @@ // destroyConstant - Remove the constant from the constant table... // -void ConstantExpr::destroyConstant(bool locked) { - ExprConstants->remove(this, locked); +void ConstantExpr::destroyConstant() { + // Implicitly locked. + ExprConstants->remove(this); destroyConstantImpl(); } @@ -2941,7 +2852,6 @@ Constant *Replacement = 0; if (isAllZeros) { - // We're Replacement = ConstantAggregateZero::get(getType()); } else { // Check to see if we have this array type already. Modified: llvm/trunk/lib/VMCore/Globals.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=73801&r1=73800&r2=73801&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Globals.cpp (original) +++ llvm/trunk/lib/VMCore/Globals.cpp Fri Jun 19 19:24:58 2009 @@ -75,7 +75,7 @@ /// Override destroyConstant to make sure it doesn't get called on /// GlobalValue's because they shouldn't be treated like other constants. -void GlobalValue::destroyConstant(bool locked) { +void GlobalValue::destroyConstant() { assert(0 && "You can't GV->destroyConstant()!"); abort(); } From resistor at mac.com Fri Jun 19 19:25:23 2009 From: resistor at mac.com (Owen Anderson) Date: Fri, 19 Jun 2009 17:25:23 -0700 Subject: [llvm-commits] [llvm] r73790 - in /llvm/trunk: include/llvm/Constant.h include/llvm/Constants.h include/llvm/GlobalValue.h include/llvm/MDNode.h lib/VMCore/ConstantFold.cpp lib/VMCore/ConstantFold.h lib/VMCore/Constants.cpp lib/VMCore/Globals.cpp In-Reply-To: <316146B5-248D-4735-8E04-F079FD6E4C6A@apple.com> References: <200906192316.n5JNGLLx028062@zion.cs.uiuc.edu> <316146B5-248D-4735-8E04-F079FD6E4C6A@apple.com> Message-ID: <64D55F0D-807F-4628-BB0D-C42DFA1586B6@mac.com> On Jun 19, 2009, at 4:37 PM, Chris Lattner wrote: > > On Jun 19, 2009, at 4:16 PM, Owen Anderson wrote: > >> Author: resistor >> Date: Fri Jun 19 18:16:19 2009 >> New Revision: 73790 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=73790&view=rev >> Log: >> Fix a serious bug that would cause deadlock during abstract type >> refinement. The constant creation >> gets involved, and we end up trying to recursively acquire a writer >> lock. The fix for this is slightly horrible, >> and involves passing a boolean "locked" parameter around in >> Constants.cpp, but it's better than having locked and >> unlocked versions of most of the code. > > Uh, this is not acceptable. We can't have "locked" escape out the > public APIs. r73801 should make you much happier. :-) --Owen From resistor at mac.com Fri Jun 19 19:26:26 2009 From: resistor at mac.com (Owen Anderson) Date: Sat, 20 Jun 2009 00:26:26 -0000 Subject: [llvm-commits] [llvm] r73802 - /llvm/trunk/lib/VMCore/ConstantFold.h Message-ID: <200906200026.n5K0QQsD030237@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 19:26:26 2009 New Revision: 73802 URL: http://llvm.org/viewvc/llvm-project?rev=73802&view=rev Log: Forgot this file. Modified: llvm/trunk/lib/VMCore/ConstantFold.h Modified: llvm/trunk/lib/VMCore/ConstantFold.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.h?rev=73802&r1=73801&r2=73802&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.h (original) +++ llvm/trunk/lib/VMCore/ConstantFold.h Fri Jun 19 19:26:26 2009 @@ -28,13 +28,11 @@ Constant *ConstantFoldCastInstruction( unsigned opcode, ///< The opcode of the cast const Constant *V, ///< The source constant - const Type *DestTy, ///< The destination type - bool locked = true + const Type *DestTy ///< The destination type ); Constant *ConstantFoldSelectInstruction(const Constant *Cond, const Constant *V1, - const Constant *V2, - bool locked = true); + const Constant *V2); Constant *ConstantFoldExtractElementInstruction(const Constant *Val, const Constant *Idx); Constant *ConstantFoldInsertElementInstruction(const Constant *Val, @@ -51,13 +49,12 @@ const unsigned* Idxs, unsigned NumIdx); Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1, - const Constant *V2, - bool locked = true); + const Constant *V2); Constant *ConstantFoldCompareInstruction(unsigned short predicate, const Constant *C1, const Constant *C2); - Constant *ConstantFoldGetElementPtr(const Constant *C, Constant* const *Idxs, - unsigned NumIdx, bool locked = true); + Constant *ConstantFoldGetElementPtr(const Constant *C, + Constant* const *Idxs, unsigned NumIdx); } // End llvm namespace #endif From resistor at mac.com Fri Jun 19 19:27:21 2009 From: resistor at mac.com (Owen Anderson) Date: Sat, 20 Jun 2009 00:27:21 -0000 Subject: [llvm-commits] [llvm] r73803 - in /llvm/trunk/include/llvm/System: Mutex.h RWMutex.h Message-ID: <200906200027.n5K0RM3c030283@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 19:27:21 2009 New Revision: 73803 URL: http://llvm.org/viewvc/llvm-project?rev=73803&view=rev Log: Add debugging code to test for various locking faux-pas's, when running in single threaded mode. This should help improve testing coverage for threading support, without having extensive actually concurrent clients yet. Modified: llvm/trunk/include/llvm/System/Mutex.h llvm/trunk/include/llvm/System/RWMutex.h Modified: llvm/trunk/include/llvm/System/Mutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Mutex.h?rev=73803&r1=73802&r2=73803&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Mutex.h (original) +++ llvm/trunk/include/llvm/System/Mutex.h Fri Jun 19 19:27:21 2009 @@ -15,6 +15,7 @@ #define LLVM_SYSTEM_MUTEX_H #include "llvm/System/Threading.h" +#include namespace llvm { @@ -85,18 +86,32 @@ /// running in multithreaded mode. template class SmartMutex : public MutexImpl { + unsigned acquired; + bool recursive; public: - explicit SmartMutex(bool recursive = true) : MutexImpl(recursive) { } + explicit SmartMutex(bool rec = true) : + MutexImpl(rec), acquired(0), recursive(rec) { } bool acquire() { if (!mt_only || llvm_is_multithreaded()) return MutexImpl::acquire(); + + // Single-threaded debugging code. This would be racy in multithreaded + // mode, but provides not sanity checks in single threaded mode. + assert((recursive || acquired == 0) && "Lock already acquired!!"); + ++acquired; return true; } bool release() { if (!mt_only || llvm_is_multithreaded()) return MutexImpl::release(); + + // Single-threaded debugging code. This would be racy in multithreaded + // mode, but provides not sanity checks in single threaded mode. + assert(((recursive && acquired) || (acquired == 1)) && + "Lock not acquired before release!"); + --acquired; return true; } Modified: llvm/trunk/include/llvm/System/RWMutex.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/RWMutex.h?rev=73803&r1=73802&r2=73803&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/RWMutex.h (original) +++ llvm/trunk/include/llvm/System/RWMutex.h Fri Jun 19 19:27:21 2009 @@ -15,6 +15,7 @@ #define LLVM_SYSTEM_RWMUTEX_H #include "llvm/System/Threading.h" +#include namespace llvm { @@ -84,30 +85,50 @@ /// running in multithreaded mode. template class SmartRWMutex : public RWMutexImpl { + unsigned readers, writers; public: - explicit SmartRWMutex() : RWMutexImpl() { } + explicit SmartRWMutex() : RWMutexImpl(), readers(0), writers(0) { } bool reader_acquire() { if (!mt_only || llvm_is_multithreaded()) return RWMutexImpl::reader_acquire(); + + // Single-threaded debugging code. This would be racy in multithreaded + // mode, but provides not sanity checks in single threaded mode. + ++readers; return true; } bool reader_release() { if (!mt_only || llvm_is_multithreaded()) return RWMutexImpl::reader_release(); + + // Single-threaded debugging code. This would be racy in multithreaded + // mode, but provides not sanity checks in single threaded mode. + assert(readers > 0 && "Reader lock not acquired before release!"); + --readers; return true; } bool writer_acquire() { if (!mt_only || llvm_is_multithreaded()) return RWMutexImpl::writer_acquire(); + + // Single-threaded debugging code. This would be racy in multithreaded + // mode, but provides not sanity checks in single threaded mode. + assert(writers == 0 && "Writer lock already acquired!"); + ++writers; return true; } bool writer_release() { if (!mt_only || llvm_is_multithreaded()) return RWMutexImpl::writer_release(); + + // Single-threaded debugging code. This would be racy in multithreaded + // mode, but provides not sanity checks in single threaded mode. + assert(writers == 1 && "Writer lock not acquired before release!"); + --writers; return true; } From gohman at apple.com Fri Jun 19 19:32:22 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 20 Jun 2009 00:32:22 -0000 Subject: [llvm-commits] [llvm] r73805 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <200906200032.n5K0WNUx030450@zion.cs.uiuc.edu> Author: djg Date: Fri Jun 19 19:32:22 2009 New Revision: 73805 URL: http://llvm.org/viewvc/llvm-project?rev=73805&view=rev Log: Use ScalarEvolution's new GetMinSignBits and GetMinLeadingZeros in the loop backedge-taken count computation of the maximum possible trip count. 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=73805&r1=73804&r2=73805&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Jun 19 19:32:22 2009 @@ -3836,9 +3836,12 @@ : getUMaxExpr(RHS, Start); // Determine the maximum constant end value. - SCEVHandle MaxEnd = isa(End) ? End : - getConstant(isSigned ? APInt::getSignedMaxValue(BitWidth) : - APInt::getMaxValue(BitWidth)); + SCEVHandle MaxEnd = + isa(End) ? End : + getConstant(isSigned ? APInt::getSignedMaxValue(BitWidth) + .ashr(GetMinSignBits(End) - 1) : + APInt::getMaxValue(BitWidth) + .lshr(GetMinLeadingZeros(End))); // Finally, we subtract these two values and divide, rounding up, to get // the number of times the backedge is executed. From resistor at mac.com Fri Jun 19 19:32:27 2009 From: resistor at mac.com (Owen Anderson) Date: Sat, 20 Jun 2009 00:32:27 -0000 Subject: [llvm-commits] [llvm] r73806 - /llvm/trunk/lib/System/RWMutex.cpp Message-ID: <200906200032.n5K0WRFH030463@zion.cs.uiuc.edu> Author: resistor Date: Fri Jun 19 19:32:27 2009 New Revision: 73806 URL: http://llvm.org/viewvc/llvm-project?rev=73806&view=rev Log: Workaround for an... interesting bug in Darwin's pthread_rwlock_init. Modified: llvm/trunk/lib/System/RWMutex.cpp Modified: llvm/trunk/lib/System/RWMutex.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/RWMutex.cpp?rev=73806&r1=73805&r2=73806&view=diff ============================================================================== --- llvm/trunk/lib/System/RWMutex.cpp (original) +++ llvm/trunk/lib/System/RWMutex.cpp Fri Jun 19 19:32:27 2009 @@ -13,6 +13,7 @@ #include "llvm/Config/config.h" #include "llvm/System/RWMutex.h" +#include //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system @@ -64,6 +65,12 @@ // Declare the pthread_rwlock data structures pthread_rwlock_t* rwlock = static_cast(malloc(sizeof(pthread_rwlock_t))); + +#ifdef __APPLE__ + // Workaround a bug/mis-feature in Darwin's pthread_rwlock_init. + bzero(rwlock, sizeof(pthread_rwlock_t)); +#endif + pthread_rwlockattr_t attr; // Initialize the rwlock attributes From gohman at apple.com Fri Jun 19 19:35:32 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 20 Jun 2009 00:35:32 -0000 Subject: [llvm-commits] [llvm] r73807 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Transforms/IndVarSimplify/ashr-tripcount.ll Message-ID: <200906200035.n5K0ZWfG030549@zion.cs.uiuc.edu> Author: djg Date: Fri Jun 19 19:35:32 2009 New Revision: 73807 URL: http://llvm.org/viewvc/llvm-project?rev=73807&view=rev Log: Generalize isLoopGuardedByCond's checking to consider two SCEVUnknowns with identical Instructions to be equal. This allows it to analze cases such as the attached testcase, where the front-end has cloned the loop controlling expression. Along with r73805, this lets IndVarSimplify eliminate all the sign-extend casts in the loop in the attached testcase. Added: llvm/trunk/test/Transforms/IndVarSimplify/ashr-tripcount.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=73807&r1=73806&r2=73807&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Jun 19 19:35:32 2009 @@ -3655,6 +3655,29 @@ return 0; } +/// HasSameValue - SCEV structural equivalence is usually sufficient for +/// testing whether two expressions are equal, however for the purposes of +/// looking for a condition guarding a loop, it can be useful to be a little +/// more general, since a front-end may have replicated the controlling +/// expression. +/// +static bool HasSameValue(const SCEVHandle &A, const SCEVHandle &B) { + // Quick check to see if they are the same SCEV. + if (A == B) return true; + + // Otherwise, if they're both SCEVUnknown, it's possible that they hold + // two different instructions with the same value. Check for this case. + if (const SCEVUnknown *AU = dyn_cast(A)) + if (const SCEVUnknown *BU = dyn_cast(B)) + if (const Instruction *AI = dyn_cast(AU->getValue())) + if (const Instruction *BI = dyn_cast(BU->getValue())) + if (AI->isIdenticalTo(BI)) + return true; + + // Otherwise assume they may have a different value. + return false; +} + /// isLoopGuardedByCond - Test whether entry to the loop is protected by /// a conditional between LHS and RHS. This is used to help avoid max /// expressions in loop trip counts. @@ -3755,9 +3778,10 @@ SCEVHandle PreCondLHSSCEV = getSCEV(PreCondLHS); SCEVHandle PreCondRHSSCEV = getSCEV(PreCondRHS); - if ((LHS == PreCondLHSSCEV && RHS == PreCondRHSSCEV) || - (LHS == getNotSCEV(PreCondRHSSCEV) && - RHS == getNotSCEV(PreCondLHSSCEV))) + if ((HasSameValue(LHS, PreCondLHSSCEV) && + HasSameValue(RHS, PreCondRHSSCEV)) || + (HasSameValue(LHS, getNotSCEV(PreCondRHSSCEV)) && + HasSameValue(RHS, getNotSCEV(PreCondLHSSCEV)))) return true; } Added: llvm/trunk/test/Transforms/IndVarSimplify/ashr-tripcount.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/ashr-tripcount.ll?rev=73807&view=auto ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/ashr-tripcount.ll (added) +++ llvm/trunk/test/Transforms/IndVarSimplify/ashr-tripcount.ll Fri Jun 19 19:35:32 2009 @@ -0,0 +1,107 @@ +; RUN: llvm-as < %s | opt -indvars | llvm-dis > %t +; RUN: grep sext %t | count 1 + +; Indvars should be able to eliminate all of the sign extensions +; inside the loop. + +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" + at pow_2_tab = external constant [0 x float] ; <[0 x float]*> [#uses=1] + at pow_2_025_tab = external constant [0 x float] ; <[0 x float]*> [#uses=1] + at i_pow_2_tab = external constant [0 x float] ; <[0 x float]*> [#uses=1] + at i_pow_2_025_tab = external constant [0 x float] ; <[0 x float]*> [#uses=1] + +define void @foo(i32 %gain, i32 %noOfLines, i32* %quaSpectrum, float* %iquaSpectrum, float* %pow4_3_tab_ptr) nounwind { +entry: + %t0 = icmp slt i32 %gain, 0 ; [#uses=1] + br i1 %t0, label %bb1, label %bb2 + +bb1: ; preds = %entry + %t1 = sub i32 0, %gain ; [#uses=1] + %t2 = sub i32 0, %gain ; [#uses=1] + br label %bb2 + +bb2: ; preds = %bb1, %entry + %pow_2_tab.pn = phi [0 x float]* [ @i_pow_2_tab, %bb1 ], [ @pow_2_tab, %entry ] ; <[0 x float]*> [#uses=1] + %.pn3.in.in = phi i32 [ %t1, %bb1 ], [ %gain, %entry ] ; [#uses=1] + %pow_2_025_tab.pn = phi [0 x float]* [ @i_pow_2_025_tab, %bb1 ], [ @pow_2_025_tab, %entry ] ; <[0 x float]*> [#uses=1] + %.pn2.in.in = phi i32 [ %t2, %bb1 ], [ %gain, %entry ] ; [#uses=1] + %.pn3.in = ashr i32 %.pn3.in.in, 2 ; [#uses=1] + %.pn2.in = and i32 %.pn2.in.in, 3 ; [#uses=1] + %.pn3 = sext i32 %.pn3.in to i64 ; [#uses=1] + %.pn2 = zext i32 %.pn2.in to i64 ; [#uses=1] + %.pn.in = getelementptr [0 x float]* %pow_2_tab.pn, i64 0, i64 %.pn3 ; [#uses=1] + %.pn1.in = getelementptr [0 x float]* %pow_2_025_tab.pn, i64 0, i64 %.pn2 ; [#uses=1] + %.pn = load float* %.pn.in ; [#uses=1] + %.pn1 = load float* %.pn1.in ; [#uses=1] + %invQuantizer.0 = fmul float %.pn, %.pn1 ; [#uses=4] + %t3 = ashr i32 %noOfLines, 2 ; [#uses=1] + %t4 = icmp sgt i32 %t3, 0 ; [#uses=1] + br i1 %t4, label %bb.nph, label %return + +bb.nph: ; preds = %bb2 + %t5 = ashr i32 %noOfLines, 2 ; [#uses=1] + br label %bb3 + +bb3: ; preds = %bb4, %bb.nph + %i.05 = phi i32 [ %t49, %bb4 ], [ 0, %bb.nph ] ; [#uses=9] + %k.04 = phi i32 [ %t48, %bb4 ], [ 0, %bb.nph ] ; [#uses=1] + %t6 = sext i32 %i.05 to i64 ; [#uses=1] + %t7 = getelementptr i32* %quaSpectrum, i64 %t6 ; [#uses=1] + %t8 = load i32* %t7, align 4 ; [#uses=1] + %t9 = zext i32 %t8 to i64 ; [#uses=1] + %t10 = getelementptr float* %pow4_3_tab_ptr, i64 %t9 ; [#uses=1] + %t11 = load float* %t10, align 4 ; [#uses=1] + %t12 = or i32 %i.05, 1 ; [#uses=1] + %t13 = sext i32 %t12 to i64 ; [#uses=1] + %t14 = getelementptr i32* %quaSpectrum, i64 %t13 ; [#uses=1] + %t15 = load i32* %t14, align 4 ; [#uses=1] + %t16 = zext i32 %t15 to i64 ; [#uses=1] + %t17 = getelementptr float* %pow4_3_tab_ptr, i64 %t16 ; [#uses=1] + %t18 = load float* %t17, align 4 ; [#uses=1] + %t19 = or i32 %i.05, 2 ; [#uses=1] + %t20 = sext i32 %t19 to i64 ; [#uses=1] + %t21 = getelementptr i32* %quaSpectrum, i64 %t20 ; [#uses=1] + %t22 = load i32* %t21, align 4 ; [#uses=1] + %t23 = zext i32 %t22 to i64 ; [#uses=1] + %t24 = getelementptr float* %pow4_3_tab_ptr, i64 %t23 ; [#uses=1] + %t25 = load float* %t24, align 4 ; [#uses=1] + %t26 = or i32 %i.05, 3 ; [#uses=1] + %t27 = sext i32 %t26 to i64 ; [#uses=1] + %t28 = getelementptr i32* %quaSpectrum, i64 %t27 ; [#uses=1] + %t29 = load i32* %t28, align 4 ; [#uses=1] + %t30 = zext i32 %t29 to i64 ; [#uses=1] + %t31 = getelementptr float* %pow4_3_tab_ptr, i64 %t30 ; [#uses=1] + %t32 = load float* %t31, align 4 ; [#uses=1] + %t33 = fmul float %t11, %invQuantizer.0 ; [#uses=1] + %t34 = sext i32 %i.05 to i64 ; [#uses=1] + %t35 = getelementptr float* %iquaSpectrum, i64 %t34 ; [#uses=1] + store float %t33, float* %t35, align 4 + %t36 = or i32 %i.05, 1 ; [#uses=1] + %t37 = fmul float %t18, %invQuantizer.0 ; [#uses=1] + %t38 = sext i32 %t36 to i64 ; [#uses=1] + %t39 = getelementptr float* %iquaSpectrum, i64 %t38 ; [#uses=1] + store float %t37, float* %t39, align 4 + %t40 = or i32 %i.05, 2 ; [#uses=1] + %t41 = fmul float %t25, %invQuantizer.0 ; [#uses=1] + %t42 = sext i32 %t40 to i64 ; [#uses=1] + %t43 = getelementptr float* %iquaSpectrum, i64 %t42 ; [#uses=1] + store float %t41, float* %t43, align 4 + %t44 = or i32 %i.05, 3 ; [#uses=1] + %t45 = fmul float %t32, %invQuantizer.0 ; [#uses=1] + %t46 = sext i32 %t44 to i64 ; [#uses=1] + %t47 = getelementptr float* %iquaSpectrum, i64 %t46 ; [#uses=1] + store float %t45, float* %t47, align 4 + %t48 = add i32 %k.04, 1 ; [#uses=2] + %t49 = add i32 %i.05, 4 ; [#uses=1] + br label %bb4 + +bb4: ; preds = %bb3 + %t50 = icmp sgt i32 %t5, %t48 ; [#uses=1] + br i1 %t50, label %bb3, label %bb4.return_crit_edge + +bb4.return_crit_edge: ; preds = %bb4 + br label %return + +return: ; preds = %bb4.return_crit_edge, %bb2 + ret void +} From gohman at apple.com Fri Jun 19 19:40:57 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 20 Jun 2009 00:40:57 -0000 Subject: [llvm-commits] [llvm] r73808 - /llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll Message-ID: <200906200040.n5K0evLJ030727@zion.cs.uiuc.edu> Author: djg Date: Fri Jun 19 19:40:56 2009 New Revision: 73808 URL: http://llvm.org/viewvc/llvm-project?rev=73808&view=rev Log: Tweak this test to be a little less unusual. Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll?rev=73808&r1=73807&r2=73808&view=diff ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll (original) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll Fri Jun 19 19:40:56 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -analyze -iv-users -disable-output | grep {Stride i64 {1,+,2}:} +; RUN: llvm-as < %s | opt -analyze -iv-users -disable-output | grep {Stride i64 {3,+,2}:} ; The value of %r is dependent on a polynomial iteration expression. @@ -13,6 +13,6 @@ br i1 %c, label %exit, label %loop exit: - %r = mul i64 %indvar, %indvar + %r = mul i64 %indvar.next, %indvar.next ret i64 %r } From sabre at nondot.org Fri Jun 19 19:47:55 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 00:47:55 -0000 Subject: [llvm-commits] [llvm] r73809 - /llvm/trunk/include/llvm/MC/MCInst.h Message-ID: <200906200048.n5K0m1al030931@zion.cs.uiuc.edu> Author: lattner Date: Fri Jun 19 19:47:37 2009 New Revision: 73809 URL: http://llvm.org/viewvc/llvm-project?rev=73809&view=rev Log: make immediates be int64_t like machineoperand. Add some apis Modified: llvm/trunk/include/llvm/MC/MCInst.h Modified: llvm/trunk/include/llvm/MC/MCInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInst.h?rev=73809&r1=73808&r2=73809&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCInst.h (original) +++ llvm/trunk/include/llvm/MC/MCInst.h Fri Jun 19 19:47:37 2009 @@ -35,7 +35,7 @@ union { unsigned RegVal; - uint64_t ImmVal; + int64_t ImmVal; }; public: @@ -57,11 +57,11 @@ RegVal = Reg; } - uint64_t getImm() const { + int64_t getImm() const { assert(isImm() && "This is not an immediate"); return ImmVal; } - void setImm(uint64_t Val) { + void setImm(int64_t Val) { assert(isImm() && "This is not an immediate"); ImmVal = Val; } @@ -70,7 +70,7 @@ Kind = kRegister; RegVal = Reg; } - void MakeImm(uint64_t Val) { + void MakeImm(int64_t Val) { Kind = kImmediate; ImmVal = Val; } @@ -85,11 +85,17 @@ public: MCInst() : Opcode(~0U) {} + void setOpcode(unsigned Op) { Opcode = Op; } + unsigned getOpcode() const { return Opcode; } DebugLoc getDebugLoc() const { return DebugLoc(); } const MCOperand &getOperand(unsigned i) const { return Operands[i]; } + void addOperand(const MCOperand &Op) { + Operands.push_back(Op); + } + }; From sabre at nondot.org Fri Jun 19 19:49:26 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 00:49:26 -0000 Subject: [llvm-commits] [llvm] r73810 - in /llvm/trunk/lib/Target/X86/AsmPrinter: X86ATTAsmPrinter.cpp X86ATTInstPrinter.cpp Message-ID: <200906200049.n5K0nRkU030981@zion.cs.uiuc.edu> Author: lattner Date: Fri Jun 19 19:49:26 2009 New Revision: 73810 URL: http://llvm.org/viewvc/llvm-project?rev=73810&view=rev Log: Start implementing translation of MachineInstr to MCInst. Next step is to make tblgen generate something more appropriate for MCInst, and generate calls to operand translation routines where needed. This includes a bunch of #if 0 code which will slowly be refactored into something sensible. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73810&r1=73809&r2=73810&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Fri Jun 19 19:49:26 2009 @@ -771,6 +771,29 @@ if (NewAsmPrinter) { O << "NEW: "; MCInst TmpInst; + + TmpInst.setOpcode(MI->getOpcode()); + + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = MI->getOperand(i); + + MCOperand MCOp; + if (MO.isReg()) { + MCOp.MakeReg(MO.getReg()); + } else if (MO.isImm()) { + MCOp.MakeImm(MO.getImm()); + } else { + assert(0 && "Unimp"); + } + + TmpInst.addOperand(MCOp); + } + + if (MI->getOpcode() == X86::LEA64_32r) { + // Should handle the 'subreg rewriting' for the lea64_32mem operand. + + } + // FIXME: Convert TmpInst. printInstruction(&TmpInst); O << "OLD: "; Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=73810&r1=73809&r2=73810&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Fri Jun 19 19:49:26 2009 @@ -28,14 +28,14 @@ unsigned char value = MI->getOperand(Op).getImm(); assert(value <= 7 && "Invalid ssecc argument!"); switch (value) { - case 0: O << "eq"; break; - case 1: O << "lt"; break; - case 2: O << "le"; break; - case 3: O << "unord"; break; - case 4: O << "neq"; break; - case 5: O << "nlt"; break; - case 6: O << "nle"; break; - case 7: O << "ord"; break; + case 0: O << "eq"; break; + case 1: O << "lt"; break; + case 2: O << "le"; break; + case 3: O << "unord"; break; + case 4: O << "neq"; break; + case 5: O << "nlt"; break; + case 6: O << "nle"; break; + case 7: O << "ord"; break; } } @@ -48,13 +48,353 @@ void X86ATTAsmPrinter::printOperand(const MCInst *MI, unsigned OpNo, const char *Modifier, bool NotRIPRel) { + //assert(Modifier == 0 && "Modifiers should not be used"); + + const MCOperand &Op = MI->getOperand(OpNo); + if (Op.isReg()) { + O << '%'; + unsigned Reg = Op.getReg(); +#if 0 + if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) { + MVT VT = (strcmp(Modifier+6,"64") == 0) ? + MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 : + ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8)); + Reg = getX86SubSuperRegister(Reg, VT); + } +#endif + O << TRI->getAsmName(Reg); + return; + } else if (Op.isImm()) { + //if (!Modifier || (strcmp(Modifier, "debug") && strcmp(Modifier, "mem") && + // strcmp(Modifier, "call"))) + O << '$'; + O << Op.getImm(); + return; + } + + O << "<>"; + + +#if 0 + const MachineOperand &MO = MI->getOperand(OpNo); + switch (MO.getType()) { + case MachineOperand::MO_Register: { + assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) && + "Virtual registers should not make it this far!"); + O << '%'; + unsigned Reg = MO.getReg(); + if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) { + MVT VT = (strcmp(Modifier+6,"64") == 0) ? + MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 : + ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8)); + Reg = getX86SubSuperRegister(Reg, VT); + } + O << TRI->getAsmName(Reg); + return; + } + + case MachineOperand::MO_Immediate: + if (!Modifier || (strcmp(Modifier, "debug") && + strcmp(Modifier, "mem") && + strcmp(Modifier, "call"))) + O << '$'; + O << MO.getImm(); + return; + case MachineOperand::MO_MachineBasicBlock: + printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm); + return; + case MachineOperand::MO_JumpTableIndex: { + bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + if (!isMemOp) O << '$'; + O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' + << MO.getIndex(); + + if (TM.getRelocationModel() == Reloc::PIC_) { + if (Subtarget->isPICStyleStub()) + O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber() + << "$pb\""; + else if (Subtarget->isPICStyleGOT()) + O << "@GOTOFF"; + } + + if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel) + O << "(%rip)"; + return; + } + case MachineOperand::MO_ConstantPoolIndex: { + bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + if (!isMemOp) O << '$'; + O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_' + << MO.getIndex(); + + if (TM.getRelocationModel() == Reloc::PIC_) { + if (Subtarget->isPICStyleStub()) + O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber() + << "$pb\""; + else if (Subtarget->isPICStyleGOT()) + O << "@GOTOFF"; + } + + printOffset(MO.getOffset()); + + if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel) + O << "(%rip)"; + return; + } + case MachineOperand::MO_GlobalAddress: { + bool isCallOp = Modifier && !strcmp(Modifier, "call"); + bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + bool needCloseParen = false; + + const GlobalValue *GV = MO.getGlobal(); + const GlobalVariable *GVar = dyn_cast(GV); + if (!GVar) { + // If GV is an alias then use the aliasee for determining + // thread-localness. + if (const GlobalAlias *GA = dyn_cast(GV)) + GVar = dyn_cast_or_null(GA->resolveAliasedGlobal(false)); + } + + bool isThreadLocal = GVar && GVar->isThreadLocal(); + + std::string Name = Mang->getValueName(GV); + decorateName(Name, GV); + + if (!isMemOp && !isCallOp) + O << '$'; + else if (Name[0] == '$') { + // The name begins with a dollar-sign. In order to avoid having it look + // like an integer immediate to the assembler, enclose it in parens. + O << '('; + needCloseParen = true; + } + + if (shouldPrintStub(TM, Subtarget)) { + // Link-once, declaration, or Weakly-linked global variables need + // non-lazily-resolved stubs + if (GV->isDeclaration() || GV->isWeakForLinker()) { + // Dynamically-resolved functions need a stub for the function. + if (isCallOp && isa(GV)) { + // Function stubs are no longer needed for Mac OS X 10.5 and up. + if (Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9) { + O << Name; + } else { + FnStubs.insert(Name); + printSuffixedName(Name, "$stub"); + } + } else if (GV->hasHiddenVisibility()) { + if (!GV->isDeclaration() && !GV->hasCommonLinkage()) + // Definition is not definitely in the current translation unit. + O << Name; + else { + HiddenGVStubs.insert(Name); + printSuffixedName(Name, "$non_lazy_ptr"); + } + } else { + GVStubs.insert(Name); + printSuffixedName(Name, "$non_lazy_ptr"); + } + } else { + if (GV->hasDLLImportLinkage()) + O << "__imp_"; + O << Name; + } + + if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_) + O << '-' << getPICLabelString(getFunctionNumber(), TAI, Subtarget); + } else { + if (GV->hasDLLImportLinkage()) { + O << "__imp_"; + } + O << Name; + + if (isCallOp) { + if (shouldPrintPLT(TM, Subtarget)) { + // Assemble call via PLT for externally visible symbols + if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() && + !GV->hasLocalLinkage()) + O << "@PLT"; + } + if (Subtarget->isTargetCygMing() && GV->isDeclaration()) + // Save function name for later type emission + FnStubs.insert(Name); + } + } + + if (GV->hasExternalWeakLinkage()) + ExtWeakSymbols.insert(GV); + + printOffset(MO.getOffset()); + + if (isThreadLocal) { + TLSModel::Model model = getTLSModel(GVar, TM.getRelocationModel()); + switch (model) { + case TLSModel::GeneralDynamic: + O << "@TLSGD"; + break; + case TLSModel::LocalDynamic: + // O << "@TLSLD"; // local dynamic not implemented + O << "@TLSGD"; + break; + case TLSModel::InitialExec: + if (Subtarget->is64Bit()) { + assert (!NotRIPRel); + O << "@GOTTPOFF(%rip)"; + } else { + O << "@INDNTPOFF"; + } + break; + case TLSModel::LocalExec: + if (Subtarget->is64Bit()) + O << "@TPOFF"; + else + O << "@NTPOFF"; + break; + default: + assert (0 && "Unknown TLS model"); + } + } else if (isMemOp) { + if (shouldPrintGOT(TM, Subtarget)) { + if (Subtarget->GVRequiresExtraLoad(GV, TM, false)) + O << "@GOT"; + else + O << "@GOTOFF"; + } else if (Subtarget->isPICStyleRIPRel() && !NotRIPRel) { + if (TM.getRelocationModel() != Reloc::Static) { + if (Subtarget->GVRequiresExtraLoad(GV, TM, false)) + O << "@GOTPCREL"; + + if (needCloseParen) { + needCloseParen = false; + O << ')'; + } + } + + // Use rip when possible to reduce code size, except when + // index or base register are also part of the address. e.g. + // foo(%rip)(%rcx,%rax,4) is not legal + O << "(%rip)"; + } + } + + if (needCloseParen) + O << ')'; + + return; + } + case MachineOperand::MO_ExternalSymbol: { + bool isCallOp = Modifier && !strcmp(Modifier, "call"); + bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + bool needCloseParen = false; + std::string Name(TAI->getGlobalPrefix()); + Name += MO.getSymbolName(); + // Print function stub suffix unless it's Mac OS X 10.5 and up. + if (isCallOp && shouldPrintStub(TM, Subtarget) && + !(Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9)) { + FnStubs.insert(Name); + printSuffixedName(Name, "$stub"); + return; + } + if (!isMemOp && !isCallOp) + O << '$'; + else if (Name[0] == '$') { + // The name begins with a dollar-sign. In order to avoid having it look + // like an integer immediate to the assembler, enclose it in parens. + O << '('; + needCloseParen = true; + } + + O << Name; + + if (shouldPrintPLT(TM, Subtarget)) { + std::string GOTName(TAI->getGlobalPrefix()); + GOTName+="_GLOBAL_OFFSET_TABLE_"; + if (Name == GOTName) + // HACK! Emit extra offset to PC during printing GOT offset to + // compensate for the size of popl instruction. The resulting code + // should look like: + // call .piclabel + // piclabel: + // popl %some_register + // addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register + O << " + [.-" + << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << ']'; + + if (isCallOp) + O << "@PLT"; + } + + if (needCloseParen) + O << ')'; + + if (!isCallOp && Subtarget->isPICStyleRIPRel()) + O << "(%rip)"; + + return; + } + default: + O << ""; return; + } +#endif } void X86ATTAsmPrinter::printLeaMemReference(const MCInst *MI, unsigned Op, const char *Modifier, bool NotRIPRel) { + const MCOperand &BaseReg = MI->getOperand(Op); + const MCOperand &IndexReg = MI->getOperand(Op+2); + const MCOperand &DispSpec = MI->getOperand(Op+3); + + NotRIPRel |= IndexReg.getReg() || BaseReg.getReg(); + if (DispSpec.isImm()) { + int64_t DispVal = DispSpec.getImm(); + if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) + O << DispVal; + } else { + abort(); + //assert(DispSpec.isGlobal() || DispSpec.isCPI() || + // DispSpec.isJTI() || DispSpec.isSymbol()); + //printOperand(MI, Op+3, "mem", NotRIPRel); + } + + if (IndexReg.getReg() || BaseReg.getReg()) { + unsigned ScaleVal = MI->getOperand(Op+1).getImm(); + unsigned BaseRegOperand = 0, IndexRegOperand = 2; + + // There are cases where we can end up with ESP/RSP in the indexreg slot. + // If this happens, swap the base/index register to support assemblers that + // don't work when the index is *SP. + // FIXME: REMOVE THIS. + if (IndexReg.getReg() == X86::ESP || IndexReg.getReg() == X86::RSP) { + assert(ScaleVal == 1 && "Scale not supported for stack pointer!"); + abort(); + //std::swap(BaseReg, IndexReg); + //std::swap(BaseRegOperand, IndexRegOperand); + } + + O << '('; + if (BaseReg.getReg()) + printOperand(MI, Op+BaseRegOperand, Modifier); + + if (IndexReg.getReg()) { + O << ','; + printOperand(MI, Op+IndexRegOperand, Modifier); + if (ScaleVal != 1) + O << ',' << ScaleVal; + } + O << ')'; + } } void X86ATTAsmPrinter::printMemReference(const MCInst *MI, unsigned Op, const char *Modifier, bool NotRIPRel){ +#if 0 + assert(isMem(MI, Op) && "Invalid memory reference!"); + MachineOperand Segment = MI->getOperand(Op+4); + if (Segment.getReg()) { + printOperand(MI, Op+4, Modifier); + O << ':'; + } + printLeaMemReference(MI, Op, Modifier, NotRIPRel); +#endif } From sabre at nondot.org Fri Jun 19 19:50:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 00:50:32 -0000 Subject: [llvm-commits] [llvm] r73811 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Message-ID: <200906200050.n5K0oWS2031022@zion.cs.uiuc.edu> Author: lattner Date: Fri Jun 19 19:50:32 2009 New Revision: 73811 URL: http://llvm.org/viewvc/llvm-project?rev=73811&view=rev Log: hook up printMemReference. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=73811&r1=73810&r2=73811&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Fri Jun 19 19:50:32 2009 @@ -388,13 +388,11 @@ void X86ATTAsmPrinter::printMemReference(const MCInst *MI, unsigned Op, const char *Modifier, bool NotRIPRel){ -#if 0 - assert(isMem(MI, Op) && "Invalid memory reference!"); - MachineOperand Segment = MI->getOperand(Op+4); + //assert(isMem(MI, Op) && "Invalid memory reference!"); + const MCOperand &Segment = MI->getOperand(Op+4); if (Segment.getReg()) { printOperand(MI, Op+4, Modifier); O << ':'; } printLeaMemReference(MI, Op, Modifier, NotRIPRel); -#endif } From dpatel at apple.com Fri Jun 19 20:00:07 2009 From: dpatel at apple.com (Devang Patel) Date: Sat, 20 Jun 2009 01:00:07 -0000 Subject: [llvm-commits] [llvm] r73813 - in /llvm/trunk/lib/Target: PowerPC/AsmPrinter/PPCAsmPrinter.cpp X86/AsmPrinter/X86ATTAsmPrinter.cpp X86/AsmPrinter/X86ATTAsmPrinter.h Message-ID: <200906200100.n5K1083X031338@zion.cs.uiuc.edu> Author: dpatel Date: Fri Jun 19 20:00:07 2009 New Revision: 73813 URL: http://llvm.org/viewvc/llvm-project?rev=73813&view=rev Log: Initialize MMI Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=73813&r1=73812&r2=73813&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Fri Jun 19 20:00:07 2009 @@ -647,6 +647,8 @@ bool PPCLinuxAsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); DW = getAnalysisIfAvailable(); + MMI = getAnalysisIfAvailable(); + assert(MMI); SwitchToSection(TAI->getTextSection()); return Result; } @@ -865,6 +867,8 @@ bool Result = AsmPrinter::doInitialization(M); DW = getAnalysisIfAvailable(); + MMI = getAnalysisIfAvailable(); + assert(MMI); // Prime text sections so they are adjacent. This reduces the likelihood a // large data or debug section causes a branch to exceed 16M limit. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73813&r1=73812&r2=73813&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Fri Jun 19 20:00:07 2009 @@ -803,6 +803,13 @@ printInstruction(MI); } +/// doInitialization +bool X86ATTAsmPrinter::doInitialization(Module &M) { + if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling()) + MMI = getAnalysisIfAvailable(); + return AsmPrinter::doInitialization(M); +} + void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) { const TargetData *TD = TM.getTargetData(); Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h?rev=73813&r1=73812&r2=73813&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Fri Jun 19 20:00:07 2009 @@ -55,6 +55,7 @@ AsmPrinter::getAnalysisUsage(AU); } + bool doInitialization(Module &M); bool doFinalization(Module &M); /// printInstruction - This method is automatically generated by tablegen From dpatel at apple.com Fri Jun 19 20:07:55 2009 From: dpatel at apple.com (Devang Patel) Date: Sat, 20 Jun 2009 01:07:55 -0000 Subject: [llvm-commits] [llvm] r73815 - in /llvm/trunk/lib/Target: ARM/AsmPrinter/ARMAsmPrinter.cpp CellSPU/AsmPrinter/SPUAsmPrinter.cpp Message-ID: <200906200107.n5K17tOD031573@zion.cs.uiuc.edu> Author: dpatel Date: Fri Jun 19 20:07:54 2009 New Revision: 73815 URL: http://llvm.org/viewvc/llvm-project?rev=73815&view=rev Log: Remove unused field. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=73815&r1=73814&r2=73815&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Fri Jun 19 20:07:54 2009 @@ -45,7 +45,6 @@ namespace { class VISIBILITY_HIDDEN ARMAsmPrinter : public AsmPrinter { DwarfWriter *DW; - MachineModuleInfo *MMI; /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can /// make the right decision when printing asm code for different targets. @@ -84,7 +83,7 @@ explicit ARMAsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T, CodeGenOpt::Level OL, bool V) - : AsmPrinter(O, TM, T, OL, V), DW(0), MMI(NULL), AFI(NULL), MCP(NULL), + : AsmPrinter(O, TM, T, OL, V), DW(0), AFI(NULL), MCP(NULL), InCPMode(false) { Subtarget = &TM.getSubtarget(); } Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=73815&r1=73814&r2=73815&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Fri Jun 19 20:07:54 2009 @@ -287,12 +287,11 @@ /// LinuxAsmPrinter - SPU assembly printer, customized for Linux class VISIBILITY_HIDDEN LinuxAsmPrinter : public SPUAsmPrinter { DwarfWriter *DW; - MachineModuleInfo *MMI; public: explicit LinuxAsmPrinter(raw_ostream &O, SPUTargetMachine &TM, const TargetAsmInfo *T, CodeGenOpt::Level F, bool V) - : SPUAsmPrinter(O, TM, T, F, V), DW(0), MMI(0) {} + : SPUAsmPrinter(O, TM, T, F, V), DW(0) {} virtual const char *getPassName() const { return "STI CBEA SPU Assembly Printer"; From evan.cheng at apple.com Fri Jun 19 23:34:55 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sat, 20 Jun 2009 04:34:55 -0000 Subject: [llvm-commits] [llvm] r73816 - in /llvm/trunk: lib/CodeGen/LiveVariables.cpp test/CodeGen/ARM/2009-06-19-RegScavengerAssert.ll Message-ID: <200906200434.n5K4Yv66004872@zion.cs.uiuc.edu> Author: evancheng Date: Fri Jun 19 23:34:51 2009 New Revision: 73816 URL: http://llvm.org/viewvc/llvm-project?rev=73816&view=rev Log: Fix PR4419: handle defs of partial uses. Added: llvm/trunk/test/CodeGen/ARM/2009-06-19-RegScavengerAssert.ll Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=73816&r1=73815&r2=73816&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Fri Jun 19 23:34:51 2009 @@ -359,12 +359,11 @@ // That is, unless we are currently processing the last reference itself. LastRefOrPartRef->addRegisterDead(Reg, TRI, true); - /* Partial uses. Mark register def dead and add implicit def of - sub-registers which are used. - FIXME: LiveIntervalAnalysis can't handle this yet! - EAX = op AL - That is, EAX def is dead but AL def extends pass it. - Enable this after live interval analysis is fixed to improve codegen! + // Partial uses. Mark register def dead and add implicit def of + // sub-registers which are used. + // EAX = op AL + // That is, EAX def is dead but AL def extends pass it. + // Enable this after live interval analysis is fixed to improve codegen! else if (!PhysRegUse[Reg]) { PhysRegDef[Reg]->addRegisterDead(Reg, TRI, true); for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); @@ -377,7 +376,7 @@ PartUses.erase(*SS); } } - } */ + } else LastRefOrPartRef->addRegisterKilled(Reg, TRI, true); return true; Added: llvm/trunk/test/CodeGen/ARM/2009-06-19-RegScavengerAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-06-19-RegScavengerAssert.ll?rev=73816&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-06-19-RegScavengerAssert.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-06-19-RegScavengerAssert.ll Fri Jun 19 23:34:51 2009 @@ -0,0 +1,30 @@ +; RUN: llvm-as < %s | llc -mtriple=armv6-eabi -mattr=+vfp2 -float-abi=hard +; PR4419 + +define float @__ieee754_acosf(float %x) nounwind { +entry: + br i1 undef, label %bb, label %bb4 + +bb: ; preds = %entry + ret float undef + +bb4: ; preds = %entry + br i1 undef, label %bb5, label %bb6 + +bb5: ; preds = %bb4 + ret float undef + +bb6: ; preds = %bb4 + br i1 undef, label %bb11, label %bb12 + +bb11: ; preds = %bb6 + %0 = tail call float @__ieee754_sqrtf(float undef) nounwind ; [#uses=1] + %1 = fmul float %0, -2.000000e+00 ; [#uses=1] + %2 = fadd float %1, 0x400921FB40000000 ; [#uses=1] + ret float %2 + +bb12: ; preds = %bb6 + ret float undef +} + +declare float @__ieee754_sqrtf(float) From edwintorok at gmail.com Sat Jun 20 01:48:56 2009 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Sat, 20 Jun 2009 09:48:56 +0300 Subject: [llvm-commits] [llvm] r73803 - in /llvm/trunk/include/llvm/System: Mutex.h RWMutex.h In-Reply-To: <200906200027.n5K0RM3c030283@zion.cs.uiuc.edu> References: <200906200027.n5K0RM3c030283@zion.cs.uiuc.edu> Message-ID: <4A3C8658.3020005@gmail.com> On 2009-06-20 03:27, Owen Anderson wrote: > Author: resistor > Date: Fri Jun 19 19:27:21 2009 > New Revision: 73803 > > URL: http://llvm.org/viewvc/llvm-project?rev=73803&view=rev > Log: > Add debugging code to test for various locking faux-pas's, when running in single threaded mode. This should help improve testing coverage for > threading support, without having extensive actually concurrent clients yet. > > Modified: > llvm/trunk/include/llvm/System/Mutex.h > llvm/trunk/include/llvm/System/RWMutex.h > > Modified: llvm/trunk/include/llvm/System/Mutex.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Mutex.h?rev=73803&r1=73802&r2=73803&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/System/Mutex.h (original) > +++ llvm/trunk/include/llvm/System/Mutex.h Fri Jun 19 19:27:21 2009 > @@ -15,6 +15,7 @@ > #define LLVM_SYSTEM_MUTEX_H > > #include "llvm/System/Threading.h" > +#include > > namespace llvm > { > @@ -85,18 +86,32 @@ > /// running in multithreaded mode. > template > class SmartMutex : public MutexImpl { > + unsigned acquired; > + bool recursive; > public: > - explicit SmartMutex(bool recursive = true) : MutexImpl(recursive) { } > + explicit SmartMutex(bool rec = true) : > + MutexImpl(rec), acquired(0), recursive(rec) { } > > bool acquire() { > if (!mt_only || llvm_is_multithreaded()) > return MutexImpl::acquire(); > + > + // Single-threaded debugging code. This would be racy in multithreaded > + // mode, but provides not sanity checks in single threaded mode. > What did you mean by "provides not"? Best regards, --Edwin From sabre at nondot.org Sat Jun 20 02:03:18 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 07:03:18 -0000 Subject: [llvm-commits] [llvm] r73817 - in /llvm/trunk: include/llvm/MC/MCInst.h include/llvm/Target/Target.td lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp lib/Target/X86/X86Instr64bit.td Message-ID: <200906200703.n5K73JK8009314@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 02:03:18 2009 New Revision: 73817 URL: http://llvm.org/viewvc/llvm-project?rev=73817&view=rev Log: implement support for lowering subregs when preparing to print LEA64_32r, eliminating a bunch of modifier logic stuff on addr modes. Implement support for printing mbb labels as operands. Modified: llvm/trunk/include/llvm/MC/MCInst.h llvm/trunk/include/llvm/Target/Target.td llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp llvm/trunk/lib/Target/X86/X86Instr64bit.td Modified: llvm/trunk/include/llvm/MC/MCInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInst.h?rev=73817&r1=73816&r2=73817&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCInst.h (original) +++ llvm/trunk/include/llvm/MC/MCInst.h Sat Jun 20 02:03:18 2009 @@ -29,13 +29,18 @@ enum MachineOperandType { kInvalid, ///< Uninitialized. kRegister, ///< Register operand. - kImmediate ///< Immediate operand. + kImmediate, ///< Immediate operand. + kMBBLabel ///< Basic block label. }; unsigned char Kind; union { unsigned RegVal; int64_t ImmVal; + struct { + unsigned FunctionNo; + unsigned BlockNo; + } MBBLabel; }; public: @@ -44,6 +49,7 @@ bool isReg() const { return Kind == kRegister; } bool isImm() const { return Kind == kImmediate; } + bool isMBBLabel() const { return Kind == kMBBLabel; } /// getReg - Returns the register number. unsigned getReg() const { @@ -66,6 +72,15 @@ ImmVal = Val; } + unsigned getMBBLabelFunction() const { + assert(isMBBLabel() && "Wrong accessor"); + return MBBLabel.FunctionNo; + } + unsigned getMBBLabelBlock() const { + assert(isMBBLabel() && "Wrong accessor"); + return MBBLabel.BlockNo; + } + void MakeReg(unsigned Reg) { Kind = kRegister; RegVal = Reg; @@ -74,6 +89,11 @@ Kind = kImmediate; ImmVal = Val; } + void MakeMBBLabel(unsigned Fn, unsigned MBB) { + Kind = kMBBLabel; + MBBLabel.FunctionNo = Fn; + MBBLabel.BlockNo = MBB; + } }; @@ -91,6 +111,7 @@ DebugLoc getDebugLoc() const { return DebugLoc(); } const MCOperand &getOperand(unsigned i) const { return Operands[i]; } + MCOperand &getOperand(unsigned i) { return Operands[i]; } void addOperand(const MCOperand &Op) { Operands.push_back(Op); Modified: llvm/trunk/include/llvm/Target/Target.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Target.td?rev=73817&r1=73816&r2=73817&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/Target.td (original) +++ llvm/trunk/include/llvm/Target/Target.td Sat Jun 20 02:03:18 2009 @@ -274,6 +274,7 @@ class Operand { ValueType Type = ty; string PrintMethod = "printOperand"; + string AsmOperandLowerMethod = ?; dag MIOperandInfo = (ops); } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73817&r1=73816&r2=73817&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Sat Jun 20 02:03:18 2009 @@ -762,6 +762,18 @@ return false; } +static void lower_lea64_32mem(MCInst *MI, unsigned OpNo) { + // Convert registers in the addr mode according to subreg64. + for (unsigned i = 0; i != 4; ++i) { + if (!MI->getOperand(i).isReg()) continue; + + unsigned Reg = MI->getOperand(i).getReg(); + if (Reg == 0) continue; + + MI->getOperand(i).setReg(getX86SubSuperRegister(Reg, MVT::i64)); + } +} + /// printMachineInstruction -- Print out a single X86 LLVM instruction MI in /// AT&T syntax to the current output stream. /// @@ -769,6 +781,21 @@ ++EmittedInsts; if (NewAsmPrinter) { + if (MI->getOpcode() == TargetInstrInfo::INLINEASM) { + O << "\t"; + printInlineAsm(MI); + return; + } else if (MI->isLabel()) { + printLabel(MI); + return; + } else if (MI->getOpcode() == TargetInstrInfo::DECLARE) { + printDeclare(MI); + return; + } else if (MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF) { + printImplicitDef(MI); + return; + } + O << "NEW: "; MCInst TmpInst; @@ -782,6 +809,8 @@ MCOp.MakeReg(MO.getReg()); } else if (MO.isImm()) { MCOp.MakeImm(MO.getImm()); + } else if (MO.isMBB()) { + MCOp.MakeMBBLabel(getFunctionNumber(), MO.getMBB()->getNumber()); } else { assert(0 && "Unimp"); } @@ -789,9 +818,9 @@ TmpInst.addOperand(MCOp); } - if (MI->getOpcode() == X86::LEA64_32r) { + if (TmpInst.getOpcode() == X86::LEA64_32r) { // Should handle the 'subreg rewriting' for the lea64_32mem operand. - + lower_lea64_32mem(&TmpInst, 1); } // FIXME: Convert TmpInst. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h?rev=73817&r1=73816&r2=73817&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Sat Jun 20 02:03:18 2009 @@ -70,10 +70,8 @@ void printOperand(const MCInst *MI, unsigned OpNo, const char *Modifier = 0, bool NotRIPRel = false); - void printMemReference(const MCInst *MI, unsigned Op, - const char *Modifier=NULL, bool NotRIPRel = false); - void printLeaMemReference(const MCInst *MI, unsigned Op, - const char *Modifier=NULL, bool NotRIPRel = false); + void printMemReference(const MCInst *MI, unsigned Op); + void printLeaMemReference(const MCInst *MI, unsigned Op); void printSSECC(const MCInst *MI, unsigned Op); void printPICLabel(const MCInst *MI, unsigned Op); @@ -111,7 +109,7 @@ printLeaMemReference(MI, OpNo); } void printlea64_32mem(const MCInst *MI, unsigned OpNo) { - printLeaMemReference(MI, OpNo, "subreg64"); + printLeaMemReference(MI, OpNo); } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=73817&r1=73816&r2=73817&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Sat Jun 20 02:03:18 2009 @@ -15,6 +15,7 @@ #define DEBUG_TYPE "asm-printer" #include "llvm/MC/MCInst.h" #include "X86ATTAsmPrinter.h" +#include "llvm/Target/TargetAsmInfo.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -25,9 +26,8 @@ #undef MachineInstr void X86ATTAsmPrinter::printSSECC(const MCInst *MI, unsigned Op) { - unsigned char value = MI->getOperand(Op).getImm(); - assert(value <= 7 && "Invalid ssecc argument!"); - switch (value) { + switch (MI->getOperand(Op).getImm()) { + default: assert(0 && "Invalid ssecc argument!"); case 0: O << "eq"; break; case 1: O << "lt"; break; case 2: O << "le"; break; @@ -48,7 +48,7 @@ void X86ATTAsmPrinter::printOperand(const MCInst *MI, unsigned OpNo, const char *Modifier, bool NotRIPRel) { - //assert(Modifier == 0 && "Modifiers should not be used"); + assert(Modifier == 0 && "Modifiers should not be used"); const MCOperand &Op = MI->getOperand(OpNo); if (Op.isReg()) { @@ -70,6 +70,15 @@ O << '$'; O << Op.getImm(); return; + } else if (Op.isMBBLabel()) { + // FIXME: Keep in sync with printBasicBlockLabel. printBasicBlockLabel + // should eventually call into this code, not the other way around. + + O << TAI->getPrivateGlobalPrefix() << "BB" << Op.getMBBLabelFunction() + << '_' << Op.getMBBLabelBlock(); + + // FIXME: with verbose asm print llvm bb name, add to operand. + return; } O << "<>"; @@ -338,9 +347,10 @@ #endif } -void X86ATTAsmPrinter::printLeaMemReference(const MCInst *MI, unsigned Op, - const char *Modifier, - bool NotRIPRel) { +void X86ATTAsmPrinter::printLeaMemReference(const MCInst *MI, unsigned Op) { + const char *Modifier = 0; + bool NotRIPRel = false; + const MCOperand &BaseReg = MI->getOperand(Op); const MCOperand &IndexReg = MI->getOperand(Op+2); const MCOperand &DispSpec = MI->getOperand(Op+3); @@ -386,13 +396,12 @@ } } -void X86ATTAsmPrinter::printMemReference(const MCInst *MI, unsigned Op, - const char *Modifier, bool NotRIPRel){ +void X86ATTAsmPrinter::printMemReference(const MCInst *MI, unsigned Op) { //assert(isMem(MI, Op) && "Invalid memory reference!"); const MCOperand &Segment = MI->getOperand(Op+4); if (Segment.getReg()) { - printOperand(MI, Op+4, Modifier); + printOperand(MI, Op+4); O << ':'; } - printLeaMemReference(MI, Op, Modifier, NotRIPRel); + printLeaMemReference(MI, Op); } Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=73817&r1=73816&r2=73817&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Sat Jun 20 02:03:18 2009 @@ -29,6 +29,7 @@ def lea64_32mem : Operand { let PrintMethod = "printlea64_32mem"; + let AsmOperandLowerMethod = "lower_lea64_32mem"; let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm); } From sabre at nondot.org Sat Jun 20 02:59:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 07:59:11 -0000 Subject: [llvm-commits] [llvm] r73818 - in /llvm/trunk/lib/Target/X86/AsmPrinter: X86ATTAsmPrinter.cpp X86ATTInstPrinter.cpp Message-ID: <200906200759.n5K7xCTU022164@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 02:59:10 2009 New Revision: 73818 URL: http://llvm.org/viewvc/llvm-project?rev=73818&view=rev Log: some comments and cleanup Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73818&r1=73817&r2=73818&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Sat Jun 20 02:59:10 2009 @@ -818,9 +818,17 @@ TmpInst.addOperand(MCOp); } - if (TmpInst.getOpcode() == X86::LEA64_32r) { - // Should handle the 'subreg rewriting' for the lea64_32mem operand. + switch (TmpInst.getOpcode()) { + case X86::LEA64_32r: + // Handle the 'subreg rewriting' for the lea64_32mem operand. lower_lea64_32mem(&TmpInst, 1); + break; + case X86::CALL64pcrel32: + case X86::CALLpcrel32: + case X86::TAILJMPd: + // The target operand is pc-relative, not an absolute reference. + // FIXME: this should be an operand property, not an asm format modifier. + ; } // FIXME: Convert TmpInst. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=73818&r1=73817&r2=73818&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Sat Jun 20 02:59:10 2009 @@ -348,7 +348,6 @@ } void X86ATTAsmPrinter::printLeaMemReference(const MCInst *MI, unsigned Op) { - const char *Modifier = 0; bool NotRIPRel = false; const MCOperand &BaseReg = MI->getOperand(Op); @@ -368,28 +367,20 @@ } if (IndexReg.getReg() || BaseReg.getReg()) { - unsigned ScaleVal = MI->getOperand(Op+1).getImm(); - unsigned BaseRegOperand = 0, IndexRegOperand = 2; - // There are cases where we can end up with ESP/RSP in the indexreg slot. // If this happens, swap the base/index register to support assemblers that // don't work when the index is *SP. // FIXME: REMOVE THIS. - if (IndexReg.getReg() == X86::ESP || IndexReg.getReg() == X86::RSP) { - assert(ScaleVal == 1 && "Scale not supported for stack pointer!"); - abort(); - //std::swap(BaseReg, IndexReg); - //std::swap(BaseRegOperand, IndexRegOperand); - } + assert(IndexReg.getReg() != X86::ESP && IndexReg.getReg() != X86::RSP); O << '('; if (BaseReg.getReg()) - printOperand(MI, Op+BaseRegOperand, Modifier); + printOperand(MI, Op); if (IndexReg.getReg()) { O << ','; - printOperand(MI, Op+IndexRegOperand, Modifier); - if (ScaleVal != 1) + printOperand(MI, Op+2); + if (MI->getOperand(Op+1).getImm() != 1) O << ',' << ScaleVal; } O << ')'; From sabre at nondot.org Sat Jun 20 03:13:12 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 08:13:12 -0000 Subject: [llvm-commits] [llvm] r73824 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Message-ID: <200906200813.n5K8DC2W022761@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 03:13:12 2009 New Revision: 73824 URL: http://llvm.org/viewvc/llvm-project?rev=73824&view=rev Log: fix edit-o Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=73824&r1=73823&r2=73824&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Sat Jun 20 03:13:12 2009 @@ -380,7 +380,8 @@ if (IndexReg.getReg()) { O << ','; printOperand(MI, Op+2); - if (MI->getOperand(Op+1).getImm() != 1) + unsigned ScaleVal = MI->getOperand(Op+1).getImm(); + if (ScaleVal != 1) O << ',' << ScaleVal; } O << ')'; From espindola at google.com Sat Jun 20 04:55:03 2009 From: espindola at google.com (Rafael Espindola) Date: Sat, 20 Jun 2009 10:55:03 +0100 Subject: [llvm-commits] [patch] fix for PR 4185 Message-ID: <38a0d8450906200255t3f501c18g1e02305f5bc1585d@mail.gmail.com> I am trying to fix http://llvm.org/pr4185. The basic problem is that inline asm can introduce a FpSET_ST0_* in the middle of a basic block and ST0 can still be alive. The patch (http://llvm.org/bugs/attachment.cgi?id=3105) fixes the included testcase. Could someone comment on it? Thanks, -- Rafael Avila de Espindola Google | Gordon House | Barrow Street | Dublin 4 | Ireland Registered in Dublin, Ireland | Registration Number: 368047 From baldrick at free.fr Sat Jun 20 08:26:11 2009 From: baldrick at free.fr (Duncan Sands) Date: Sat, 20 Jun 2009 13:26:11 -0000 Subject: [llvm-commits] [llvm] r73827 - /llvm/trunk/docs/LangRef.html Message-ID: <200906201326.n5KDQCY2000902@zion.cs.uiuc.edu> Author: baldrick Date: Sat Jun 20 08:26:06 2009 New Revision: 73827 URL: http://llvm.org/viewvc/llvm-project?rev=73827&view=rev Log: Clarify that if the alignment is zero then an alignment compatible with the type will be used (at least the ABI alignment). Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=73827&r1=73826&r2=73827&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Sat Jun 20 08:26:06 2009 @@ -3532,9 +3532,10 @@ bytes of memory from the operating system and returns a pointer of the appropriate type to the program. If "NumElements" is specified, it is the number of elements allocated, otherwise "NumElements" is defaulted to be one. -If a constant alignment is specified, the value result of the allocation is guaranteed to -be aligned to at least that boundary. If not specified, or if zero, the target can -choose to align the allocation on any convenient boundary.

    +If a constant alignment is specified, the value result of the allocation is +guaranteed to be aligned to at least that boundary. If not specified, or if +zero, the target can choose to align the allocation on any convenient boundary +compatible with the type.

    'type' must be a sized type.

    @@ -3625,9 +3626,10 @@ bytes of memory on the runtime stack, returning a pointer of the appropriate type to the program. If "NumElements" is specified, it is the number of elements allocated, otherwise "NumElements" is defaulted to be one. -If a constant alignment is specified, the value result of the allocation is guaranteed -to be aligned to at least that boundary. If not specified, or if zero, the target -can choose to align the allocation on any convenient boundary.

    +If a constant alignment is specified, the value result of the allocation is +guaranteed to be aligned to at least that boundary. If not specified, or if +zero, the target can choose to align the allocation on any convenient boundary +compatible with the type.

    'type' may be any sized type.

    From mai4 at uiuc.edu Sat Jun 20 12:21:00 2009 From: mai4 at uiuc.edu (Haohui Mai) Date: Sat, 20 Jun 2009 17:21:00 -0000 Subject: [llvm-commits] [poolalloc] r73828 - /poolalloc/trunk/include/dsa/DSSupport.h Message-ID: <200906201721.n5KHL0ec007718@zion.cs.uiuc.edu> Author: mai4 Date: Sat Jun 20 12:20:59 2009 New Revision: 73828 URL: http://llvm.org/viewvc/llvm-project?rev=73828&view=rev Log: Remove the inline attributes for setTo() and getNode(). The compiler complains it cannot find function body for them, which means it cannot inline these functions. Therefore I just remove the attribute to make the compiler happy. Modified: poolalloc/trunk/include/dsa/DSSupport.h Modified: poolalloc/trunk/include/dsa/DSSupport.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSSupport.h?rev=73828&r1=73827&r2=73828&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DSSupport.h (original) +++ poolalloc/trunk/include/dsa/DSSupport.h Sat Jun 20 12:20:59 2009 @@ -94,7 +94,7 @@ bool isNull() const { return N == 0; } // Allow explicit conversion to DSNode... - inline DSNode *getNode() const; // Defined inline in DSNode.h + DSNode *getNode() const; // Defined inline in DSNode.h unsigned getOffset() const { assert(!isForwarding() && "This is a forwarding NH, call getNode() first!"); return Offset; @@ -109,7 +109,7 @@ Offset = O; } - inline void setTo(DSNode *N, unsigned O) const; // Defined inline in DSNode.h + void setTo(DSNode *N, unsigned O) const; // Defined inline in DSNode.h void addEdgeTo(unsigned LinkNo, const DSNodeHandle &N); void addEdgeTo(const DSNodeHandle &N) { addEdgeTo(0, N); } From sabre at nondot.org Sat Jun 20 14:34:10 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 19:34:10 -0000 Subject: [llvm-commits] [llvm] r73829 - in /llvm/trunk/lib/Target/X86: AsmPrinter/X86ATTAsmPrinter.cpp AsmPrinter/X86ATTAsmPrinter.h AsmPrinter/X86ATTInstPrinter.cpp AsmPrinter/X86IntelAsmPrinter.cpp AsmPrinter/X86IntelAsmPrinter.h X86Instr64bit.td X86InstrInfo.td Message-ID: <200906201934.n5KJYBX4011742@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 14:34:09 2009 New Revision: 73829 URL: http://llvm.org/viewvc/llvm-project?rev=73829&view=rev Log: eliminate the "call" operand modifier from the asm descriptions, modeling it as a pcrel immediate instead. This gets pc-rel weirdness out of the main printoperand codepath. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73829&r1=73828&r2=73829&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Sat Jun 20 14:34:09 2009 @@ -296,6 +296,136 @@ return ST->isPICStyleStub() && TM.getRelocationModel() != Reloc::Static; } +/// print_pcrel_imm - This is used to print an immediate value that ends up +/// being encoded as a pc-relative value. These print slightly differently, for +/// example, a $ is not emitted. +void X86ATTAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo) { + const MachineOperand &MO = MI->getOperand(OpNo); + switch (MO.getType()) { + default: assert(0 && "Unknown pcrel immediate operand"); + case MachineOperand::MO_Immediate: + O << MO.getImm(); + return; + case MachineOperand::MO_MachineBasicBlock: + printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm); + return; + + case MachineOperand::MO_GlobalAddress: { + const GlobalValue *GV = MO.getGlobal(); + std::string Name = Mang->getValueName(GV); + decorateName(Name, GV); + + bool needCloseParen = false; + if (Name[0] == '$') { + // The name begins with a dollar-sign. In order to avoid having it look + // like an integer immediate to the assembler, enclose it in parens. + O << '('; + needCloseParen = true; + } + + if (shouldPrintStub(TM, Subtarget)) { + // Link-once, declaration, or Weakly-linked global variables need + // non-lazily-resolved stubs + if (GV->isDeclaration() || GV->isWeakForLinker()) { + // Dynamically-resolved functions need a stub for the function. + if (isa(GV)) { + // Function stubs are no longer needed for Mac OS X 10.5 and up. + if (Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9) { + O << Name; + } else { + FnStubs.insert(Name); + printSuffixedName(Name, "$stub"); + } + } else if (GV->hasHiddenVisibility()) { + if (!GV->isDeclaration() && !GV->hasCommonLinkage()) + // Definition is not definitely in the current translation unit. + O << Name; + else { + HiddenGVStubs.insert(Name); + printSuffixedName(Name, "$non_lazy_ptr"); + } + } else { + GVStubs.insert(Name); + printSuffixedName(Name, "$non_lazy_ptr"); + } + } else { + if (GV->hasDLLImportLinkage()) + O << "__imp_"; + O << Name; + } + } else { + if (GV->hasDLLImportLinkage()) { + O << "__imp_"; + } + O << Name; + + if (shouldPrintPLT(TM, Subtarget)) { + // Assemble call via PLT for externally visible symbols + if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() && + !GV->hasLocalLinkage()) + O << "@PLT"; + } + if (Subtarget->isTargetCygMing() && GV->isDeclaration()) + // Save function name for later type emission + FnStubs.insert(Name); + } + + if (GV->hasExternalWeakLinkage()) + ExtWeakSymbols.insert(GV); + + printOffset(MO.getOffset()); + + if (needCloseParen) + O << ')'; + return; + } + + case MachineOperand::MO_ExternalSymbol: { + bool needCloseParen = false; + std::string Name(TAI->getGlobalPrefix()); + Name += MO.getSymbolName(); + // Print function stub suffix unless it's Mac OS X 10.5 and up. + if (shouldPrintStub(TM, Subtarget) && + !(Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9)) { + FnStubs.insert(Name); + printSuffixedName(Name, "$stub"); + return; + } + + if (Name[0] == '$') { + // The name begins with a dollar-sign. In order to avoid having it look + // like an integer immediate to the assembler, enclose it in parens. + O << '('; + needCloseParen = true; + } + + O << Name; + + if (shouldPrintPLT(TM, Subtarget)) { + std::string GOTName(TAI->getGlobalPrefix()); + GOTName+="_GLOBAL_OFFSET_TABLE_"; + if (Name == GOTName) + // HACK! Emit extra offset to PC during printing GOT offset to + // compensate for the size of popl instruction. The resulting code + // should look like: + // call .piclabel + // piclabel: + // popl %some_register + // addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register + O << " + [.-" + << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << ']'; + + O << "@PLT"; + } + + if (needCloseParen) + O << ')'; + + return; + } + } +} + void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, const char *Modifier, bool NotRIPRel) { const MachineOperand &MO = MI->getOperand(OpNo); @@ -317,12 +447,13 @@ case MachineOperand::MO_Immediate: if (!Modifier || (strcmp(Modifier, "debug") && - strcmp(Modifier, "mem") && - strcmp(Modifier, "call"))) + strcmp(Modifier, "mem"))) O << '$'; O << MO.getImm(); return; case MachineOperand::MO_MachineBasicBlock: + // FIXME: REMOVE + assert(0 && "labels should only be used as pc-relative values"); printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm); return; case MachineOperand::MO_JumpTableIndex: { @@ -364,7 +495,6 @@ return; } case MachineOperand::MO_GlobalAddress: { - bool isCallOp = Modifier && !strcmp(Modifier, "call"); bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool needCloseParen = false; @@ -382,7 +512,7 @@ std::string Name = Mang->getValueName(GV); decorateName(Name, GV); - if (!isMemOp && !isCallOp) + if (!isMemOp) O << '$'; else if (Name[0] == '$') { // The name begins with a dollar-sign. In order to avoid having it look @@ -396,15 +526,7 @@ // non-lazily-resolved stubs if (GV->isDeclaration() || GV->isWeakForLinker()) { // Dynamically-resolved functions need a stub for the function. - if (isCallOp && isa(GV)) { - // Function stubs are no longer needed for Mac OS X 10.5 and up. - if (Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9) { - O << Name; - } else { - FnStubs.insert(Name); - printSuffixedName(Name, "$stub"); - } - } else if (GV->hasHiddenVisibility()) { + if (GV->hasHiddenVisibility()) { if (!GV->isDeclaration() && !GV->hasCommonLinkage()) // Definition is not definitely in the current translation unit. O << Name; @@ -422,25 +544,13 @@ O << Name; } - if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_) + if (TM.getRelocationModel() == Reloc::PIC_) O << '-' << getPICLabelString(getFunctionNumber(), TAI, Subtarget); } else { if (GV->hasDLLImportLinkage()) { O << "__imp_"; } O << Name; - - if (isCallOp) { - if (shouldPrintPLT(TM, Subtarget)) { - // Assemble call via PLT for externally visible symbols - if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() && - !GV->hasLocalLinkage()) - O << "@PLT"; - } - if (Subtarget->isTargetCygMing() && GV->isDeclaration()) - // Save function name for later type emission - FnStubs.insert(Name); - } } if (GV->hasExternalWeakLinkage()) @@ -505,19 +615,13 @@ return; } case MachineOperand::MO_ExternalSymbol: { - bool isCallOp = Modifier && !strcmp(Modifier, "call"); bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool needCloseParen = false; std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName(); + // Print function stub suffix unless it's Mac OS X 10.5 and up. - if (isCallOp && shouldPrintStub(TM, Subtarget) && - !(Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9)) { - FnStubs.insert(Name); - printSuffixedName(Name, "$stub"); - return; - } - if (!isMemOp && !isCallOp) + if (!isMemOp) O << '$'; else if (Name[0] == '$') { // The name begins with a dollar-sign. In order to avoid having it look @@ -541,17 +645,13 @@ // addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register O << " + [.-" << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << ']'; - - if (isCallOp) - O << "@PLT"; } if (needCloseParen) O << ')'; - if (!isCallOp && Subtarget->isPICStyleRIPRel()) + if (Subtarget->isPICStyleRIPRel()) O << "(%rip)"; - return; } default: Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h?rev=73829&r1=73828&r2=73829&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h Sat Jun 20 14:34:09 2009 @@ -74,7 +74,8 @@ void printLeaMemReference(const MCInst *MI, unsigned Op); void printSSECC(const MCInst *MI, unsigned Op); void printPICLabel(const MCInst *MI, unsigned Op); - + void print_pcrel_imm(const MCInst *MI, unsigned OpNo); + void printi8mem(const MCInst *MI, unsigned OpNo) { printMemReference(MI, OpNo); } @@ -117,6 +118,7 @@ // These methods are used by the tablegen'erated instruction printer. void printOperand(const MachineInstr *MI, unsigned OpNo, const char *Modifier = 0, bool NotRIPRel = false); + void print_pcrel_imm(const MachineInstr *MI, unsigned OpNo); void printi8mem(const MachineInstr *MI, unsigned OpNo) { printMemReference(MI, OpNo); } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=73829&r1=73828&r2=73829&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Sat Jun 20 14:34:09 2009 @@ -46,6 +46,24 @@ } +/// print_pcrel_imm - This is used to print an immediate value that ends up +/// being encoded as a pc-relative value. These print slightly differently, for +/// example, a $ is not emitted. +void X86ATTAsmPrinter::print_pcrel_imm(const MCInst *MI, unsigned OpNo) { + const MCOperand &Op = MI->getOperand(OpNo); + + if (Op.isImm()) + O << Op.getImm(); + else if (Op.isMBBLabel()) + // FIXME: Keep in sync with printBasicBlockLabel. printBasicBlockLabel + // should eventually call into this code, not the other way around. + O << TAI->getPrivateGlobalPrefix() << "BB" << Op.getMBBLabelFunction() + << '_' << Op.getMBBLabelBlock(); + else + assert(0 && "Unknown pcrel immediate operand"); +} + + void X86ATTAsmPrinter::printOperand(const MCInst *MI, unsigned OpNo, const char *Modifier, bool NotRIPRel) { assert(Modifier == 0 && "Modifiers should not be used"); @@ -71,6 +89,7 @@ O << Op.getImm(); return; } else if (Op.isMBBLabel()) { + assert(0 && "labels should only be used as pc-relative values"); // FIXME: Keep in sync with printBasicBlockLabel. printBasicBlockLabel // should eventually call into this code, not the other way around. @@ -109,9 +128,6 @@ O << '$'; O << MO.getImm(); return; - case MachineOperand::MO_MachineBasicBlock: - printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm); - return; case MachineOperand::MO_JumpTableIndex: { bool isMemOp = Modifier && !strcmp(Modifier, "mem"); if (!isMemOp) O << '$'; @@ -389,7 +405,6 @@ } void X86ATTAsmPrinter::printMemReference(const MCInst *MI, unsigned Op) { - //assert(isMem(MI, Op) && "Invalid memory reference!"); const MCOperand &Segment = MI->getOperand(Op+4); if (Segment.getReg()) { printOperand(MI, Op+4); Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp?rev=73829&r1=73828&r2=73829&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Sat Jun 20 14:34:09 2009 @@ -224,6 +224,8 @@ O << MO.getImm(); return; case MachineOperand::MO_MachineBasicBlock: + // FIXME: REMOVE + assert(0 && "labels should only be used as pc-relative values"); printBasicBlockLabel(MO.getMBB()); return; case MachineOperand::MO_JumpTableIndex: { @@ -243,14 +245,13 @@ return; } case MachineOperand::MO_GlobalAddress: { - bool isCallOp = Modifier && !strcmp(Modifier, "call"); bool isMemOp = Modifier && !strcmp(Modifier, "mem"); GlobalValue *GV = MO.getGlobal(); std::string Name = Mang->getValueName(GV); decorateName(Name, GV); - if (!isMemOp && !isCallOp) O << "OFFSET "; + if (!isMemOp) O << "OFFSET "; if (GV->hasDLLImportLinkage()) { // FIXME: This should be fixed with full support of stdcall & fastcall // CC's @@ -261,8 +262,6 @@ return; } case MachineOperand::MO_ExternalSymbol: { - bool isCallOp = Modifier && !strcmp(Modifier, "call"); - if (!isCallOp) O << "OFFSET "; O << TAI->getGlobalPrefix() << MO.getSymbolName(); return; } @@ -271,6 +270,39 @@ } } +void X86IntelAsmPrinter::print_pcrel_imm(const MachineInstr *MI, unsigned OpNo){ + const MachineOperand &MO = MI->getOperand(OpNo); + switch (MO.getType()) { + default: assert(0 && "Unknown pcrel immediate operand"); + case MachineOperand::MO_Immediate: + O << MO.getImm(); + return; + case MachineOperand::MO_MachineBasicBlock: + printBasicBlockLabel(MO.getMBB()); + return; + + case MachineOperand::MO_GlobalAddress: { + GlobalValue *GV = MO.getGlobal(); + std::string Name = Mang->getValueName(GV); + decorateName(Name, GV); + + if (GV->hasDLLImportLinkage()) { + // FIXME: This should be fixed with full support of stdcall & fastcall + // CC's + O << "__imp_"; + } + O << Name; + printOffset(MO.getOffset()); + return; + } + + case MachineOperand::MO_ExternalSymbol: + O << TAI->getGlobalPrefix() << MO.getSymbolName(); + return; + } +} + + void X86IntelAsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op, const char *Modifier) { Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h?rev=73829&r1=73828&r2=73829&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h Sat Jun 20 14:34:09 2009 @@ -52,6 +52,9 @@ printOp(MO, Modifier); } } + + void print_pcrel_imm(const MachineInstr *MI, unsigned OpNo); + void printi8mem(const MachineInstr *MI, unsigned OpNo) { O << "BYTE PTR "; Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=73829&r1=73828&r2=73829&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Sat Jun 20 14:34:09 2009 @@ -19,6 +19,14 @@ // 64-bits but only 32 bits are significant. def i64i32imm : Operand; + +// 64-bits but only 32 bits are significant, and those bits are treated as being +// pc relative. +def i64i32imm_pcrel : Operand { + let PrintMethod = "print_pcrel_imm"; +} + + // 64-bits but only 8 bits are significant. def i64i8imm : Operand; @@ -115,8 +123,8 @@ // that the offset between an arbitrary immediate and the call will fit in // the 32-bit pcrel field that we have. def CALL64pcrel32 : Ii32<0xE8, RawFrm, - (outs), (ins i64i32imm:$dst, variable_ops), - "call\t${dst:call}", []>, + (outs), (ins i64i32imm_pcrel:$dst, variable_ops), + "call\t$dst", []>, Requires<[In64BitMode]>; def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops), "call\t{*}$dst", [(X86call GR64:$dst)]>; Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=73829&r1=73828&r2=73829&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Sat Jun 20 14:34:09 2009 @@ -163,6 +163,11 @@ // X86 Operand Definitions. // +def i32imm_pcrel : Operand { + let PrintMethod = "print_pcrel_imm"; +} + + // *mem - Operand definitions for the funky X86 addressing mode operands. // class X86MemOperand : Operand { @@ -206,8 +211,10 @@ // 32-bits but only 8 bits are significant. def i32i8imm : Operand; -// Branch targets have OtherVT type. -def brtarget : Operand; +// Branch targets have OtherVT type and print as pc-relative values. +def brtarget : Operand { + let PrintMethod = "print_pcrel_imm"; +} //===----------------------------------------------------------------------===// // X86 Complex Pattern Definitions. @@ -561,8 +568,9 @@ XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], Uses = [ESP] in { - def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops), - "call\t${dst:call}", []>; + def CALLpcrel32 : Ii32<0xE8, RawFrm, + (outs), (ins i32imm_pcrel:$dst,variable_ops), + "call\t$dst", []>; def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops), "call\t{*}$dst", [(X86call GR32:$dst)]>; def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops), @@ -587,7 +595,7 @@ let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in - def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL", + def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL", []>; let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL", From sabre at nondot.org Sat Jun 20 14:34:47 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 19:34:47 -0000 Subject: [llvm-commits] [llvm] r73830 - in /llvm/trunk/lib/Target/X86/AsmPrinter: X86ATTAsmPrinter.cpp X86ATTInstPrinter.cpp X86IntelAsmPrinter.cpp Message-ID: <200906201934.n5KJYlI3011773@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 14:34:47 2009 New Revision: 73830 URL: http://llvm.org/viewvc/llvm-project?rev=73830&view=rev Log: remove dead code, the main codepath never has to deal with MBB's. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73830&r1=73829&r2=73830&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Sat Jun 20 14:34:47 2009 @@ -451,11 +451,6 @@ O << '$'; O << MO.getImm(); return; - case MachineOperand::MO_MachineBasicBlock: - // FIXME: REMOVE - assert(0 && "labels should only be used as pc-relative values"); - printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm); - return; case MachineOperand::MO_JumpTableIndex: { bool isMemOp = Modifier && !strcmp(Modifier, "mem"); if (!isMemOp) O << '$'; Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=73830&r1=73829&r2=73830&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Sat Jun 20 14:34:47 2009 @@ -88,16 +88,6 @@ O << '$'; O << Op.getImm(); return; - } else if (Op.isMBBLabel()) { - assert(0 && "labels should only be used as pc-relative values"); - // FIXME: Keep in sync with printBasicBlockLabel. printBasicBlockLabel - // should eventually call into this code, not the other way around. - - O << TAI->getPrivateGlobalPrefix() << "BB" << Op.getMBBLabelFunction() - << '_' << Op.getMBBLabelBlock(); - - // FIXME: with verbose asm print llvm bb name, add to operand. - return; } O << "<>"; Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp?rev=73830&r1=73829&r2=73830&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Sat Jun 20 14:34:47 2009 @@ -223,11 +223,6 @@ case MachineOperand::MO_Immediate: O << MO.getImm(); return; - case MachineOperand::MO_MachineBasicBlock: - // FIXME: REMOVE - assert(0 && "labels should only be used as pc-relative values"); - printBasicBlockLabel(MO.getMBB()); - return; case MachineOperand::MO_JumpTableIndex: { bool isMemOp = Modifier && !strcmp(Modifier, "mem"); if (!isMemOp) O << "OFFSET "; From sabre at nondot.org Sat Jun 20 14:43:09 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 19:43:09 -0000 Subject: [llvm-commits] [llvm] r73831 - /llvm/trunk/test/CodeGen/X86/tls1.ll Message-ID: <200906201943.n5KJh9sx012005@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 14:43:09 2009 New Revision: 73831 URL: http://llvm.org/viewvc/llvm-project?rev=73831&view=rev Log: no need for unwind info here. Modified: llvm/trunk/test/CodeGen/X86/tls1.ll Modified: llvm/trunk/test/CodeGen/X86/tls1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls1.ll?rev=73831&r1=73830&r2=73831&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tls1.ll (original) +++ llvm/trunk/test/CodeGen/X86/tls1.ll Sat Jun 20 14:43:09 2009 @@ -5,7 +5,7 @@ @i = thread_local global i32 15 -define i32 @f() { +define i32 @f() nounwind { entry: %tmp1 = load i32* @i ret i32 %tmp1 From sabre at nondot.org Sat Jun 20 14:48:26 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 19:48:26 -0000 Subject: [llvm-commits] [llvm] r73832 - /llvm/trunk/test/CodeGen/X86/tls2-pic.ll Message-ID: <200906201948.n5KJmQVQ012147@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 14:48:26 2009 New Revision: 73832 URL: http://llvm.org/viewvc/llvm-project?rev=73832&view=rev Log: no need for unwind info Modified: llvm/trunk/test/CodeGen/X86/tls2-pic.ll Modified: llvm/trunk/test/CodeGen/X86/tls2-pic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls2-pic.ll?rev=73832&r1=73831&r2=73832&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tls2-pic.ll (original) +++ llvm/trunk/test/CodeGen/X86/tls2-pic.ll Sat Jun 20 14:48:26 2009 @@ -7,7 +7,7 @@ @i = thread_local global i32 15 -define i32* @f() { +define i32* @f() nounwind { entry: ret i32* @i } From sabre at nondot.org Sat Jun 20 15:38:49 2009 From: sabre at nondot.org (Chris Lattner) Date: Sat, 20 Jun 2009 20:38:49 -0000 Subject: [llvm-commits] [llvm] r73834 - in /llvm/trunk: lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/tls1-pic.ll test/CodeGen/X86/tls2-pic.ll test/CodeGen/X86/tls3-pic.ll test/CodeGen/X86/tls4-pic.ll Message-ID: <200906202038.n5KKcnVv013791@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 15:38:48 2009 New Revision: 73834 URL: http://llvm.org/viewvc/llvm-project?rev=73834&view=rev Log: change TLS_ADDR lowering to lower to a real mem operand, instead of matching as a global with that gets printed with the :mem modifier. All operands to lea's should be handled with the lea32mem operand kind, and this allows the TLS stuff to do this. There are several better ways to do this, but I went for the minimal change since I can't really test this (beyond make check). This also makes the use of EBX explicit in the operand list in the 32-bit, instead of implicit in the instruction. Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/test/CodeGen/X86/tls1-pic.ll llvm/trunk/test/CodeGen/X86/tls2-pic.ll llvm/trunk/test/CodeGen/X86/tls3-pic.ll llvm/trunk/test/CodeGen/X86/tls4-pic.ll Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=73834&r1=73833&r2=73834&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Sat Jun 20 15:38:48 2009 @@ -167,6 +167,8 @@ SDValue &Segment); bool SelectLEAAddr(SDValue Op, SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp); + bool SelectTLSADDRAddr(SDValue Op, SDValue N, SDValue &Base, + SDValue &Scale, SDValue &Index, SDValue &Disp); bool SelectScalarSSELoad(SDValue Op, SDValue Pred, SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp, @@ -1293,6 +1295,32 @@ return false; } +/// SelectTLSADDRAddr - This is only run on TargetGlobalTLSAddress nodes. +bool X86DAGToDAGISel::SelectTLSADDRAddr(SDValue Op, SDValue N, SDValue &Base, + SDValue &Scale, SDValue &Index, + SDValue &Disp) { + assert(Op.getOpcode() == X86ISD::TLSADDR); + assert(N.getOpcode() == ISD::TargetGlobalTLSAddress); + const GlobalAddressSDNode *GA = cast(N); + + X86ISelAddressMode AM; + AM.GV = GA->getGlobal(); + AM.Disp += GA->getOffset(); + AM.Base.Reg = CurDAG->getRegister(0, N.getValueType()); + + if (N.getValueType() == MVT::i32) { + AM.Scale = 1; + AM.IndexReg = CurDAG->getRegister(X86::EBX, MVT::i32); + } else { + AM.IndexReg = CurDAG->getRegister(0, MVT::i64); + } + + SDValue Segment; + getAddressOperands(AM, Base, Scale, Index, Disp, Segment); + return true; +} + + bool X86DAGToDAGISel::TryFoldLoad(SDValue P, SDValue N, SDValue &Base, SDValue &Scale, SDValue &Index, SDValue &Disp, Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=73834&r1=73833&r2=73834&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Sat Jun 20 15:38:48 2009 @@ -48,6 +48,9 @@ [add, mul, X86mul_imm, shl, or, frameindex, X86Wrapper], []>; +def tls64addr : ComplexPattern; + //===----------------------------------------------------------------------===// // Pattern fragments. // @@ -1330,13 +1333,13 @@ XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], Uses = [RSP] in -def TLS_addr64 : I<0, Pseudo, (outs), (ins i64imm:$sym), +def TLS_addr64 : I<0, Pseudo, (outs), (ins lea64mem:$sym), ".byte\t0x66; " - "leaq\t${sym:mem}(%rip), %rdi; " + "leaq\t$sym(%rip), %rdi; " ".word\t0x6666; " "rex64; " "call\t__tls_get_addr at PLT", - [(X86tlsaddr tglobaltlsaddr:$sym)]>, + [(X86tlsaddr tls64addr:$sym)]>, Requires<[In64BitMode]>; let AddedComplexity = 5 in Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=73834&r1=73833&r2=73834&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Sat Jun 20 15:38:48 2009 @@ -224,6 +224,8 @@ def addr : ComplexPattern; def lea32addr : ComplexPattern; +def tls32addr : ComplexPattern; //===----------------------------------------------------------------------===// // X86 Instruction Predicate Definitions. @@ -3112,11 +3114,11 @@ MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], - Uses = [ESP, EBX] in -def TLS_addr32 : I<0, Pseudo, (outs), (ins i32imm:$sym), - "leal\t${sym:mem}(,%ebx,1), %eax; " + Uses = [ESP] in +def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym), + "leal\t$sym, %eax; " "call\t___tls_get_addr at PLT", - [(X86tlsaddr tglobaltlsaddr:$sym)]>, + [(X86tlsaddr tls32addr:$sym)]>, Requires<[In32BitMode]>; let AddedComplexity = 5 in Modified: llvm/trunk/test/CodeGen/X86/tls1-pic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls1-pic.ll?rev=73834&r1=73833&r2=73834&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tls1-pic.ll (original) +++ llvm/trunk/test/CodeGen/X86/tls1-pic.ll Sat Jun 20 15:38:48 2009 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu -relocation-model=pic > %t -; RUN: grep {leal i at TLSGD(,%ebx,1), %eax} %t +; RUN: grep {leal i at TLSGD(,%ebx), %eax} %t ; RUN: grep {call ___tls_get_addr at PLT} %t ; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu -relocation-model=pic > %t2 ; RUN: grep {leaq i at TLSGD(%rip), %rdi} %t2 Modified: llvm/trunk/test/CodeGen/X86/tls2-pic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls2-pic.ll?rev=73834&r1=73833&r2=73834&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tls2-pic.ll (original) +++ llvm/trunk/test/CodeGen/X86/tls2-pic.ll Sat Jun 20 15:38:48 2009 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu -relocation-model=pic > %t -; RUN: grep {leal i at TLSGD(,%ebx,1), %eax} %t +; RUN: grep {leal i at TLSGD(,%ebx), %eax} %t ; RUN: grep {call ___tls_get_addr at PLT} %t ; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu -relocation-model=pic > %t2 ; RUN: grep {leaq i at TLSGD(%rip), %rdi} %t2 Modified: llvm/trunk/test/CodeGen/X86/tls3-pic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls3-pic.ll?rev=73834&r1=73833&r2=73834&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tls3-pic.ll (original) +++ llvm/trunk/test/CodeGen/X86/tls3-pic.ll Sat Jun 20 15:38:48 2009 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu -relocation-model=pic > %t -; RUN: grep {leal i at TLSGD(,%ebx,1), %eax} %t +; RUN: grep {leal i at TLSGD(,%ebx), %eax} %t ; RUN: grep {call ___tls_get_addr at PLT} %t ; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu -relocation-model=pic > %t2 ; RUN: grep {leaq i at TLSGD(%rip), %rdi} %t2 Modified: llvm/trunk/test/CodeGen/X86/tls4-pic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls4-pic.ll?rev=73834&r1=73833&r2=73834&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tls4-pic.ll (original) +++ llvm/trunk/test/CodeGen/X86/tls4-pic.ll Sat Jun 20 15:38:48 2009 @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu -relocation-model=pic > %t -; RUN: grep {leal i at TLSGD(,%ebx,1), %eax} %t +; RUN: grep {leal i at TLSGD(,%ebx), %eax} %t ; RUN: grep {call ___tls_get_addr at PLT} %t ; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu -relocation-model=pic > %t2 ; RUN: grep {leaq i at TLSGD(%rip), %rdi} %t2 From sabre at nondot.org Sat Jun 20 20:15:56 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 01:15:56 -0000 Subject: [llvm-commits] [llvm] r73835 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/ConstProp/div-zero.ll Message-ID: <200906210115.n5L1FuX2021605@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 20:15:55 2009 New Revision: 73835 URL: http://llvm.org/viewvc/llvm-project?rev=73835&view=rev Log: implement PR4424: 0/x is always 0 for integer division. Added: llvm/trunk/test/Transforms/ConstProp/div-zero.ll Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=73835&r1=73834&r2=73835&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Sat Jun 20 20:15:55 2009 @@ -773,6 +773,13 @@ } } } + + // 0 / x -> 0. + if ((Opcode == Instruction::UDiv || + Opcode == Instruction::SDiv) && + CI1->isZero()) + return const_cast(C1); + } else if (const ConstantFP *CFP1 = dyn_cast(C1)) { if (const ConstantFP *CFP2 = dyn_cast(C2)) { APFloat C1V = CFP1->getValueAPF(); Added: llvm/trunk/test/Transforms/ConstProp/div-zero.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/div-zero.ll?rev=73835&view=auto ============================================================================== --- llvm/trunk/test/Transforms/ConstProp/div-zero.ll (added) +++ llvm/trunk/test/Transforms/ConstProp/div-zero.ll Sat Jun 20 20:15:55 2009 @@ -0,0 +1,12 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i32 0} +; PR4424 +declare void @ext() + +define i32 @foo(i32 %ptr) { +entry: + %zero = sub i32 %ptr, %ptr ; [#uses=1] + %div_zero = sdiv i32 %zero, ptrtoint (i32* getelementptr (i32* null, +i32 1) to i32) ; [#uses=1] + ret i32 %div_zero +} + From sabre at nondot.org Sat Jun 20 20:27:55 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 01:27:55 -0000 Subject: [llvm-commits] [llvm] r73836 - in /llvm/trunk/lib/Target/X86: AsmPrinter/X86ATTAsmPrinter.cpp X86Subtarget.h Message-ID: <200906210127.n5L1RuDX021964@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 20:27:55 2009 New Revision: 73836 URL: http://llvm.org/viewvc/llvm-project?rev=73836&view=rev Log: cosmetic changes. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73836&r1=73835&r2=73836&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Sat Jun 20 20:27:55 2009 @@ -490,7 +490,7 @@ return; } case MachineOperand::MO_GlobalAddress: { - bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool needCloseParen = false; const GlobalValue *GV = MO.getGlobal(); @@ -499,7 +499,7 @@ // If GV is an alias then use the aliasee for determining // thread-localness. if (const GlobalAlias *GA = dyn_cast(GV)) - GVar = dyn_cast_or_null(GA->resolveAliasedGlobal(false)); + GVar =dyn_cast_or_null(GA->resolveAliasedGlobal(false)); } bool isThreadLocal = GVar && GVar->isThreadLocal(); @@ -542,9 +542,8 @@ if (TM.getRelocationModel() == Reloc::PIC_) O << '-' << getPICLabelString(getFunctionNumber(), TAI, Subtarget); } else { - if (GV->hasDLLImportLinkage()) { + if (GV->hasDLLImportLinkage()) O << "__imp_"; - } O << Name; } Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=73836&r1=73835&r2=73836&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Sat Jun 20 20:27:55 2009 @@ -173,7 +173,7 @@ bool isPICStyleGOT() const { return PICStyle == PICStyles::GOT; } bool isPICStyleStub() const { return PICStyle == PICStyles::Stub; } bool isPICStyleRIPRel() const { return PICStyle == PICStyles::RIPRel; } - bool isPICStyleWinPIC() const { return PICStyle == PICStyles:: WinPIC; } + bool isPICStyleWinPIC() const { return PICStyle == PICStyles::WinPIC; } /// getDarwinVers - Return the darwin version number, 8 = tiger, 9 = leopard. unsigned getDarwinVers() const { return DarwinVers; } From sabre at nondot.org Sat Jun 20 20:48:54 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 01:48:54 -0000 Subject: [llvm-commits] [llvm] r73837 - in /llvm/trunk/lib/Target/X86/AsmPrinter: X86ATTAsmPrinter.cpp X86ATTInstPrinter.cpp Message-ID: <200906210148.n5L1mtkf022569@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 20:48:49 2009 New Revision: 73837 URL: http://llvm.org/viewvc/llvm-project?rev=73837&view=rev Log: remove #if 0 code Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73837&r1=73836&r2=73837&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Sat Jun 20 20:48:49 2009 @@ -917,12 +917,6 @@ // Handle the 'subreg rewriting' for the lea64_32mem operand. lower_lea64_32mem(&TmpInst, 1); break; - case X86::CALL64pcrel32: - case X86::CALLpcrel32: - case X86::TAILJMPd: - // The target operand is pc-relative, not an absolute reference. - // FIXME: this should be an operand property, not an asm format modifier. - ; } // FIXME: Convert TmpInst. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=73837&r1=73836&r2=73837&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Sat Jun 20 20:48:49 2009 @@ -83,274 +83,13 @@ O << TRI->getAsmName(Reg); return; } else if (Op.isImm()) { - //if (!Modifier || (strcmp(Modifier, "debug") && strcmp(Modifier, "mem") && - // strcmp(Modifier, "call"))) + //if (!Modifier || (strcmp(Modifier, "debug") && strcmp(Modifier, "mem"))) O << '$'; O << Op.getImm(); return; } O << "<>"; - - -#if 0 - const MachineOperand &MO = MI->getOperand(OpNo); - switch (MO.getType()) { - case MachineOperand::MO_Register: { - assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) && - "Virtual registers should not make it this far!"); - O << '%'; - unsigned Reg = MO.getReg(); - if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) { - MVT VT = (strcmp(Modifier+6,"64") == 0) ? - MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 : - ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8)); - Reg = getX86SubSuperRegister(Reg, VT); - } - O << TRI->getAsmName(Reg); - return; - } - - case MachineOperand::MO_Immediate: - if (!Modifier || (strcmp(Modifier, "debug") && - strcmp(Modifier, "mem") && - strcmp(Modifier, "call"))) - O << '$'; - O << MO.getImm(); - return; - case MachineOperand::MO_JumpTableIndex: { - bool isMemOp = Modifier && !strcmp(Modifier, "mem"); - if (!isMemOp) O << '$'; - O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' - << MO.getIndex(); - - if (TM.getRelocationModel() == Reloc::PIC_) { - if (Subtarget->isPICStyleStub()) - O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber() - << "$pb\""; - else if (Subtarget->isPICStyleGOT()) - O << "@GOTOFF"; - } - - if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel) - O << "(%rip)"; - return; - } - case MachineOperand::MO_ConstantPoolIndex: { - bool isMemOp = Modifier && !strcmp(Modifier, "mem"); - if (!isMemOp) O << '$'; - O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_' - << MO.getIndex(); - - if (TM.getRelocationModel() == Reloc::PIC_) { - if (Subtarget->isPICStyleStub()) - O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber() - << "$pb\""; - else if (Subtarget->isPICStyleGOT()) - O << "@GOTOFF"; - } - - printOffset(MO.getOffset()); - - if (isMemOp && Subtarget->isPICStyleRIPRel() && !NotRIPRel) - O << "(%rip)"; - return; - } - case MachineOperand::MO_GlobalAddress: { - bool isCallOp = Modifier && !strcmp(Modifier, "call"); - bool isMemOp = Modifier && !strcmp(Modifier, "mem"); - bool needCloseParen = false; - - const GlobalValue *GV = MO.getGlobal(); - const GlobalVariable *GVar = dyn_cast(GV); - if (!GVar) { - // If GV is an alias then use the aliasee for determining - // thread-localness. - if (const GlobalAlias *GA = dyn_cast(GV)) - GVar = dyn_cast_or_null(GA->resolveAliasedGlobal(false)); - } - - bool isThreadLocal = GVar && GVar->isThreadLocal(); - - std::string Name = Mang->getValueName(GV); - decorateName(Name, GV); - - if (!isMemOp && !isCallOp) - O << '$'; - else if (Name[0] == '$') { - // The name begins with a dollar-sign. In order to avoid having it look - // like an integer immediate to the assembler, enclose it in parens. - O << '('; - needCloseParen = true; - } - - if (shouldPrintStub(TM, Subtarget)) { - // Link-once, declaration, or Weakly-linked global variables need - // non-lazily-resolved stubs - if (GV->isDeclaration() || GV->isWeakForLinker()) { - // Dynamically-resolved functions need a stub for the function. - if (isCallOp && isa(GV)) { - // Function stubs are no longer needed for Mac OS X 10.5 and up. - if (Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9) { - O << Name; - } else { - FnStubs.insert(Name); - printSuffixedName(Name, "$stub"); - } - } else if (GV->hasHiddenVisibility()) { - if (!GV->isDeclaration() && !GV->hasCommonLinkage()) - // Definition is not definitely in the current translation unit. - O << Name; - else { - HiddenGVStubs.insert(Name); - printSuffixedName(Name, "$non_lazy_ptr"); - } - } else { - GVStubs.insert(Name); - printSuffixedName(Name, "$non_lazy_ptr"); - } - } else { - if (GV->hasDLLImportLinkage()) - O << "__imp_"; - O << Name; - } - - if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_) - O << '-' << getPICLabelString(getFunctionNumber(), TAI, Subtarget); - } else { - if (GV->hasDLLImportLinkage()) { - O << "__imp_"; - } - O << Name; - - if (isCallOp) { - if (shouldPrintPLT(TM, Subtarget)) { - // Assemble call via PLT for externally visible symbols - if (!GV->hasHiddenVisibility() && !GV->hasProtectedVisibility() && - !GV->hasLocalLinkage()) - O << "@PLT"; - } - if (Subtarget->isTargetCygMing() && GV->isDeclaration()) - // Save function name for later type emission - FnStubs.insert(Name); - } - } - - if (GV->hasExternalWeakLinkage()) - ExtWeakSymbols.insert(GV); - - printOffset(MO.getOffset()); - - if (isThreadLocal) { - TLSModel::Model model = getTLSModel(GVar, TM.getRelocationModel()); - switch (model) { - case TLSModel::GeneralDynamic: - O << "@TLSGD"; - break; - case TLSModel::LocalDynamic: - // O << "@TLSLD"; // local dynamic not implemented - O << "@TLSGD"; - break; - case TLSModel::InitialExec: - if (Subtarget->is64Bit()) { - assert (!NotRIPRel); - O << "@GOTTPOFF(%rip)"; - } else { - O << "@INDNTPOFF"; - } - break; - case TLSModel::LocalExec: - if (Subtarget->is64Bit()) - O << "@TPOFF"; - else - O << "@NTPOFF"; - break; - default: - assert (0 && "Unknown TLS model"); - } - } else if (isMemOp) { - if (shouldPrintGOT(TM, Subtarget)) { - if (Subtarget->GVRequiresExtraLoad(GV, TM, false)) - O << "@GOT"; - else - O << "@GOTOFF"; - } else if (Subtarget->isPICStyleRIPRel() && !NotRIPRel) { - if (TM.getRelocationModel() != Reloc::Static) { - if (Subtarget->GVRequiresExtraLoad(GV, TM, false)) - O << "@GOTPCREL"; - - if (needCloseParen) { - needCloseParen = false; - O << ')'; - } - } - - // Use rip when possible to reduce code size, except when - // index or base register are also part of the address. e.g. - // foo(%rip)(%rcx,%rax,4) is not legal - O << "(%rip)"; - } - } - - if (needCloseParen) - O << ')'; - - return; - } - case MachineOperand::MO_ExternalSymbol: { - bool isCallOp = Modifier && !strcmp(Modifier, "call"); - bool isMemOp = Modifier && !strcmp(Modifier, "mem"); - bool needCloseParen = false; - std::string Name(TAI->getGlobalPrefix()); - Name += MO.getSymbolName(); - // Print function stub suffix unless it's Mac OS X 10.5 and up. - if (isCallOp && shouldPrintStub(TM, Subtarget) && - !(Subtarget->isTargetDarwin() && Subtarget->getDarwinVers() >= 9)) { - FnStubs.insert(Name); - printSuffixedName(Name, "$stub"); - return; - } - if (!isMemOp && !isCallOp) - O << '$'; - else if (Name[0] == '$') { - // The name begins with a dollar-sign. In order to avoid having it look - // like an integer immediate to the assembler, enclose it in parens. - O << '('; - needCloseParen = true; - } - - O << Name; - - if (shouldPrintPLT(TM, Subtarget)) { - std::string GOTName(TAI->getGlobalPrefix()); - GOTName+="_GLOBAL_OFFSET_TABLE_"; - if (Name == GOTName) - // HACK! Emit extra offset to PC during printing GOT offset to - // compensate for the size of popl instruction. The resulting code - // should look like: - // call .piclabel - // piclabel: - // popl %some_register - // addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register - O << " + [.-" - << getPICLabelString(getFunctionNumber(), TAI, Subtarget) << ']'; - - if (isCallOp) - O << "@PLT"; - } - - if (needCloseParen) - O << ')'; - - if (!isCallOp && Subtarget->isPICStyleRIPRel()) - O << "(%rip)"; - - return; - } - default: - O << ""; return; - } -#endif } void X86ATTAsmPrinter::printLeaMemReference(const MCInst *MI, unsigned Op) { From sabre at nondot.org Sat Jun 20 20:52:00 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 01:52:00 -0000 Subject: [llvm-commits] [llvm] r73838 - /llvm/trunk/include/llvm/CodeGen/MachineOperand.h Message-ID: <200906210152.n5L1q0cP022665@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 20:52:00 2009 New Revision: 73838 URL: http://llvm.org/viewvc/llvm-project?rev=73838&view=rev Log: fit in 80 cols Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=73838&r1=73837&r2=73838&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Sat Jun 20 20:52:00 2009 @@ -33,15 +33,15 @@ class MachineOperand { public: enum MachineOperandType { - MO_Register, ///< Register operand. - MO_Immediate, ///< Immediate operand - MO_FPImmediate, ///< Floating-point immediate operand - MO_MachineBasicBlock, ///< MachineBasicBlock reference - MO_FrameIndex, ///< Abstract Stack Frame Index - MO_ConstantPoolIndex, ///< Address of indexed Constant in Constant Pool - MO_JumpTableIndex, ///< Address of indexed Jump Table for switch - MO_ExternalSymbol, ///< Name of external global symbol - MO_GlobalAddress ///< Address of a global value + MO_Register, ///< Register operand. + MO_Immediate, ///< Immediate operand + MO_FPImmediate, ///< Floating-point immediate operand + MO_MachineBasicBlock, ///< MachineBasicBlock reference + MO_FrameIndex, ///< Abstract Stack Frame Index + MO_ConstantPoolIndex, ///< Address of indexed Constant in Constant Pool + MO_JumpTableIndex, ///< Address of indexed Jump Table for switch + MO_ExternalSymbol, ///< Name of external global symbol + MO_GlobalAddress ///< Address of a global value }; private: From nicholas at mxc.ca Sat Jun 20 20:56:42 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 21 Jun 2009 01:56:42 -0000 Subject: [llvm-commits] [llvm] r73839 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/ConstProp/2009-06-20-constexpr-zero-lhs.ll Message-ID: <200906210156.n5L1ugSl022803@zion.cs.uiuc.edu> Author: nicholas Date: Sat Jun 20 20:56:41 2009 New Revision: 73839 URL: http://llvm.org/viewvc/llvm-project?rev=73839&view=rev Log: Expand this test to handle more cases (remainder and shifts) of zero. Added: llvm/trunk/test/Transforms/ConstProp/2009-06-20-constexpr-zero-lhs.ll - copied, changed from r73835, llvm/trunk/test/Transforms/ConstProp/div-zero.ll Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=73839&r1=73838&r2=73839&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Sat Jun 20 20:56:41 2009 @@ -629,7 +629,7 @@ } } - // Handle simplifications of the RHS when a constant int. + // Handle simplifications when the RHS is a constant int. if (const ConstantInt *CI2 = dyn_cast(C2)) { switch (Opcode) { case Instruction::Add: @@ -773,13 +773,20 @@ } } } - - // 0 / x -> 0. - if ((Opcode == Instruction::UDiv || - Opcode == Instruction::SDiv) && - CI1->isZero()) - return const_cast(C1); - + + switch (Opcode) { + case Instruction::SDiv: + case Instruction::UDiv: + case Instruction::URem: + case Instruction::SRem: + case Instruction::LShr: + case Instruction::AShr: + case Instruction::Shl: + if (CI1->equalsInt(0)) return const_cast(C1); + break; + default: + break; + } } else if (const ConstantFP *CFP1 = dyn_cast(C1)) { if (const ConstantFP *CFP2 = dyn_cast(C2)) { APFloat C1V = CFP1->getValueAPF(); Copied: llvm/trunk/test/Transforms/ConstProp/2009-06-20-constexpr-zero-lhs.ll (from r73835, llvm/trunk/test/Transforms/ConstProp/div-zero.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/2009-06-20-constexpr-zero-lhs.ll?p2=llvm/trunk/test/Transforms/ConstProp/2009-06-20-constexpr-zero-lhs.ll&p1=llvm/trunk/test/Transforms/ConstProp/div-zero.ll&r1=73835&r2=73839&rev=73839&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ConstProp/div-zero.ll (original) +++ llvm/trunk/test/Transforms/ConstProp/2009-06-20-constexpr-zero-lhs.ll Sat Jun 20 20:56:41 2009 @@ -1,12 +1,11 @@ -; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i32 0} +; RUN: llvm-as < %s | llvm-dis | not grep ptrtoint ; PR4424 -declare void @ext() - -define i32 @foo(i32 %ptr) { -entry: - %zero = sub i32 %ptr, %ptr ; [#uses=1] - %div_zero = sdiv i32 %zero, ptrtoint (i32* getelementptr (i32* null, -i32 1) to i32) ; [#uses=1] - ret i32 %div_zero -} + at G = external global i32 + at test1 = constant i32 sdiv (i32 0, i32 ptrtoint (i32* @G to i32)) + at test2 = constant i32 udiv (i32 0, i32 ptrtoint (i32* @G to i32)) + at test3 = constant i32 srem (i32 0, i32 ptrtoint (i32* @G to i32)) + at test4 = constant i32 urem (i32 0, i32 ptrtoint (i32* @G to i32)) + at test5 = constant i32 lshr (i32 0, i32 ptrtoint (i32* @G to i32)) + at test6 = constant i32 ashr (i32 0, i32 ptrtoint (i32* @G to i32)) + at test7 = constant i32 shl (i32 0, i32 ptrtoint (i32* @G to i32)) From sabre at nondot.org Sat Jun 20 21:22:34 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 02:22:34 -0000 Subject: [llvm-commits] [llvm] r73840 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200906210222.n5L2MYeC023542@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 21:22:34 2009 New Revision: 73840 URL: http://llvm.org/viewvc/llvm-project?rev=73840&view=rev Log: indentation fix Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=73840&r1=73839&r2=73840&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Jun 20 21:22:34 2009 @@ -4437,9 +4437,8 @@ // emit "addl x at ntpoff,%eax" (local exec) or "addl x at indntpoff,%eax" (initial // exec) - SDValue TGA = DAG.getTargetGlobalAddress(GA->getGlobal(), - GA->getValueType(0), - GA->getOffset()); + SDValue TGA = DAG.getTargetGlobalAddress(GA->getGlobal(), GA->getValueType(0), + GA->getOffset()); SDValue Offset = DAG.getNode(X86ISD::Wrapper, dl, PtrVT, TGA); if (model == TLSModel::InitialExec) From sabre at nondot.org Sat Jun 20 21:22:54 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 02:22:54 -0000 Subject: [llvm-commits] [llvm] r73841 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Message-ID: <200906210222.n5L2MsZe023562@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 21:22:53 2009 New Revision: 73841 URL: http://llvm.org/viewvc/llvm-project?rev=73841&view=rev Log: simplify closing paren and (rip) printing. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=73841&r1=73840&r2=73841&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Sat Jun 20 21:22:53 2009 @@ -552,6 +552,10 @@ printOffset(MO.getOffset()); + if (needCloseParen) + O << ')'; + + bool isRIPRelative = false; if (isThreadLocal) { TLSModel::Model model = getTLSModel(GVar, TM.getRelocationModel()); switch (model) { @@ -565,7 +569,8 @@ case TLSModel::InitialExec: if (Subtarget->is64Bit()) { assert (!NotRIPRel); - O << "@GOTTPOFF(%rip)"; + O << "@GOTTPOFF"; + isRIPRelative = true; } else { O << "@INDNTPOFF"; } @@ -585,27 +590,23 @@ O << "@GOT"; else O << "@GOTOFF"; - } else if (Subtarget->isPICStyleRIPRel() && !NotRIPRel) { + } else if (Subtarget->isPICStyleRIPRel() && + !NotRIPRel) { if (TM.getRelocationModel() != Reloc::Static) { if (Subtarget->GVRequiresExtraLoad(GV, TM, false)) O << "@GOTPCREL"; - - if (needCloseParen) { - needCloseParen = false; - O << ')'; - } } - - // Use rip when possible to reduce code size, except when - // index or base register are also part of the address. e.g. - // foo(%rip)(%rcx,%rax,4) is not legal - O << "(%rip)"; + + isRIPRelative = true; } } - if (needCloseParen) - O << ')'; - + // Use rip when possible to reduce code size, except when + // index or base register are also part of the address. e.g. + // foo(%rip)(%rcx,%rax,4) is not legal. + if (isRIPRelative) + O << "(%rip)"; + return; } case MachineOperand::MO_ExternalSymbol: { From sabre at nondot.org Sat Jun 20 22:36:56 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 03:36:56 -0000 Subject: [llvm-commits] [llvm] r73842 - in /llvm/trunk: include/llvm/Support/SourceMgr.h lib/Support/SourceMgr.cpp utils/TableGen/Record.h utils/TableGen/TGLexer.cpp utils/TableGen/TGParser.h utils/TableGen/TGSourceMgr.cpp utils/TableGen/TGSourceMgr.h Message-ID: <200906210336.n5L3av95025826@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 22:36:54 2009 New Revision: 73842 URL: http://llvm.org/viewvc/llvm-project?rev=73842&view=rev Log: move TGSourceMgr class out of TableGen into libsupport. Added: llvm/trunk/include/llvm/Support/SourceMgr.h - copied, changed from r73828, llvm/trunk/utils/TableGen/TGSourceMgr.h llvm/trunk/lib/Support/SourceMgr.cpp - copied, changed from r73828, llvm/trunk/utils/TableGen/TGSourceMgr.cpp Removed: llvm/trunk/utils/TableGen/TGSourceMgr.cpp llvm/trunk/utils/TableGen/TGSourceMgr.h Modified: llvm/trunk/utils/TableGen/Record.h llvm/trunk/utils/TableGen/TGLexer.cpp llvm/trunk/utils/TableGen/TGParser.h Copied: llvm/trunk/include/llvm/Support/SourceMgr.h (from r73828, llvm/trunk/utils/TableGen/TGSourceMgr.h) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SourceMgr.h?p2=llvm/trunk/include/llvm/Support/SourceMgr.h&p1=llvm/trunk/utils/TableGen/TGSourceMgr.h&r1=73828&r2=73842&rev=73842&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGSourceMgr.h (original) +++ llvm/trunk/include/llvm/Support/SourceMgr.h Sat Jun 20 22:36:54 2009 @@ -1,4 +1,4 @@ -//===- TGSourceMgr.h - Manager for Source Buffers & Diagnostics -*- C++ -*-===// +//===- SourceMgr.h - Manager for Source Buffers & Diagnostics ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // -// This file declares the TGSourceMgr class. +// This file declares the SourceMgr class. This class is used as a simple +// substrate for diagnostics, #include handling, and other low level things for +// simple parsers. // //===----------------------------------------------------------------------===// Copied: llvm/trunk/lib/Support/SourceMgr.cpp (from r73828, llvm/trunk/utils/TableGen/TGSourceMgr.cpp) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SourceMgr.cpp?p2=llvm/trunk/lib/Support/SourceMgr.cpp&p1=llvm/trunk/utils/TableGen/TGSourceMgr.cpp&r1=73828&r2=73842&rev=73842&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGSourceMgr.cpp (original) +++ llvm/trunk/lib/Support/SourceMgr.cpp Sat Jun 20 22:36:54 2009 @@ -1,4 +1,4 @@ -//===- TGSourceMgr.cpp - Manager for Source Buffers & Diagnostics ---------===// +//===- SourceMgr.cpp - Manager for Simple Source Buffers & Diagnostics ----===// // // The LLVM Compiler Infrastructure // @@ -7,11 +7,13 @@ // //===----------------------------------------------------------------------===// // -// This file implements the TGSourceMgr class. +// This file implements the SourceMgr class. This class is used as a simple +// substrate for diagnostics, #include handling, and other low level things for +// simple parsers. // //===----------------------------------------------------------------------===// -#include "TGSourceMgr.h" +#include "llvm/Support/SourceMgr.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; Modified: llvm/trunk/utils/TableGen/Record.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=73842&r1=73841&r2=73842&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/Record.h (original) +++ llvm/trunk/utils/TableGen/Record.h Sat Jun 20 22:36:54 2009 @@ -15,7 +15,7 @@ #ifndef RECORD_H #define RECORD_H -#include "TGSourceMgr.h" +#include "llvm/Support/SourceMgr.h" #include "llvm/Support/DataTypes.h" #include #include Modified: llvm/trunk/utils/TableGen/TGLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.cpp?rev=73842&r1=73841&r2=73842&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGLexer.cpp (original) +++ llvm/trunk/utils/TableGen/TGLexer.cpp Sat Jun 20 22:36:54 2009 @@ -12,7 +12,7 @@ //===----------------------------------------------------------------------===// #include "TGLexer.h" -#include "TGSourceMgr.h" +#include "llvm/Support/SourceMgr.h" #include "llvm/Support/Streams.h" #include "llvm/Support/MemoryBuffer.h" #include Modified: llvm/trunk/utils/TableGen/TGParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.h?rev=73842&r1=73841&r2=73842&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.h (original) +++ llvm/trunk/utils/TableGen/TGParser.h Sat Jun 20 22:36:54 2009 @@ -15,7 +15,7 @@ #define TGPARSER_H #include "TGLexer.h" -#include "TGSourceMgr.h" +#include "llvm/Support/SourceMgr.h" #include namespace llvm { Removed: llvm/trunk/utils/TableGen/TGSourceMgr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGSourceMgr.cpp?rev=73841&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/TGSourceMgr.cpp (original) +++ llvm/trunk/utils/TableGen/TGSourceMgr.cpp (removed) @@ -1,105 +0,0 @@ -//===- TGSourceMgr.cpp - Manager for Source Buffers & Diagnostics ---------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the TGSourceMgr class. -// -//===----------------------------------------------------------------------===// - -#include "TGSourceMgr.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/raw_ostream.h" -using namespace llvm; - -TGSourceMgr::~TGSourceMgr() { - while (!Buffers.empty()) { - delete Buffers.back().Buffer; - Buffers.pop_back(); - } -} - -/// FindBufferContainingLoc - Return the ID of the buffer containing the -/// specified location, returning -1 if not found. -int TGSourceMgr::FindBufferContainingLoc(TGLoc Loc) const { - for (unsigned i = 0, e = Buffers.size(); i != e; ++i) - if (Loc.getPointer() >= Buffers[i].Buffer->getBufferStart() && - // Use <= here so that a pointer to the null at the end of the buffer - // is included as part of the buffer. - Loc.getPointer() <= Buffers[i].Buffer->getBufferEnd()) - return i; - return -1; -} - -/// FindLineNumber - Find the line number for the specified location in the -/// specified file. This is not a fast method. -unsigned TGSourceMgr::FindLineNumber(TGLoc Loc, int BufferID) const { - if (BufferID == -1) BufferID = FindBufferContainingLoc(Loc); - assert(BufferID != -1 && "Invalid Location!"); - - MemoryBuffer *Buff = getBufferInfo(BufferID).Buffer; - - // Count the number of \n's between the start of the file and the specified - // location. - unsigned LineNo = 1; - - const char *Ptr = Buff->getBufferStart(); - - for (; TGLoc::getFromPointer(Ptr) != Loc; ++Ptr) - if (*Ptr == '\n') ++LineNo; - return LineNo; -} - -void TGSourceMgr::PrintIncludeStack(TGLoc IncludeLoc) const { - if (IncludeLoc == TGLoc()) return; // Top of stack. - - int CurBuf = FindBufferContainingLoc(IncludeLoc); - assert(CurBuf != -1 && "Invalid or unspecified location!"); - - PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc); - - errs() << "Included from " - << getBufferInfo(CurBuf).Buffer->getBufferIdentifier() - << ":" << FindLineNumber(IncludeLoc, CurBuf) << ":\n"; -} - - -void TGSourceMgr::PrintError(TGLoc ErrorLoc, const std::string &Msg) const { - raw_ostream &OS = errs(); - - // First thing to do: find the current buffer containing the specified - // location. - int CurBuf = FindBufferContainingLoc(ErrorLoc); - assert(CurBuf != -1 && "Invalid or unspecified location!"); - - PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc); - - MemoryBuffer *CurMB = getBufferInfo(CurBuf).Buffer; - - - OS << "Parsing " << CurMB->getBufferIdentifier() << ":" - << FindLineNumber(ErrorLoc, CurBuf) << ": "; - - OS << Msg << "\n"; - - // Scan backward to find the start of the line. - const char *LineStart = ErrorLoc.getPointer(); - while (LineStart != CurMB->getBufferStart() && - LineStart[-1] != '\n' && LineStart[-1] != '\r') - --LineStart; - // Get the end of the line. - const char *LineEnd = ErrorLoc.getPointer(); - while (LineEnd != CurMB->getBufferEnd() && - LineEnd[0] != '\n' && LineEnd[0] != '\r') - ++LineEnd; - // Print out the line. - OS << std::string(LineStart, LineEnd) << "\n"; - // Print out spaces before the caret. - for (const char *Pos = LineStart; Pos != ErrorLoc.getPointer(); ++Pos) - OS << (*Pos == '\t' ? '\t' : ' '); - OS << "^\n"; -} Removed: llvm/trunk/utils/TableGen/TGSourceMgr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGSourceMgr.h?rev=73841&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/TGSourceMgr.h (original) +++ llvm/trunk/utils/TableGen/TGSourceMgr.h (removed) @@ -1,106 +0,0 @@ -//===- TGSourceMgr.h - Manager for Source Buffers & Diagnostics -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the TGSourceMgr class. -// -//===----------------------------------------------------------------------===// - -#ifndef TGSOURCEMGR_H -#define TGSOURCEMGR_H - -#include -#include -#include - -namespace llvm { - class MemoryBuffer; - class TGSourceMgr; - -class TGLoc { - const char *Ptr; -public: - TGLoc() : Ptr(0) {} - TGLoc(const TGLoc &RHS) : Ptr(RHS.Ptr) {} - - bool operator==(const TGLoc &RHS) const { return RHS.Ptr == Ptr; } - bool operator!=(const TGLoc &RHS) const { return RHS.Ptr != Ptr; } - - const char *getPointer() const { return Ptr; } - - static TGLoc getFromPointer(const char *Ptr) { - TGLoc L; - L.Ptr = Ptr; - return L; - } -}; - -/// TGSourceMgr - This owns the files read by tblgen, handles include stacks, -/// and handles printing of diagnostics. -class TGSourceMgr { - struct SrcBuffer { - /// Buffer - The memory buffer for the file. - MemoryBuffer *Buffer; - - /// IncludeLoc - This is the location of the parent include, or null if at - /// the top level. - TGLoc IncludeLoc; - }; - - /// Buffers - This is all of the buffers that we are reading from. - std::vector Buffers; - - TGSourceMgr(const TGSourceMgr&); // DO NOT IMPLEMENT - void operator=(const TGSourceMgr&); // DO NOT IMPLEMENT -public: - TGSourceMgr() {} - ~TGSourceMgr(); - - const SrcBuffer &getBufferInfo(unsigned i) const { - assert(i < Buffers.size() && "Invalid Buffer ID!"); - return Buffers[i]; - } - - const MemoryBuffer *getMemoryBuffer(unsigned i) const { - assert(i < Buffers.size() && "Invalid Buffer ID!"); - return Buffers[i].Buffer; - } - - TGLoc getParentIncludeLoc(unsigned i) const { - assert(i < Buffers.size() && "Invalid Buffer ID!"); - return Buffers[i].IncludeLoc; - } - - unsigned AddNewSourceBuffer(MemoryBuffer *F, TGLoc IncludeLoc) { - SrcBuffer NB; - NB.Buffer = F; - NB.IncludeLoc = IncludeLoc; - Buffers.push_back(NB); - return Buffers.size()-1; - } - - /// FindBufferContainingLoc - Return the ID of the buffer containing the - /// specified location, returning -1 if not found. - int FindBufferContainingLoc(TGLoc Loc) const; - - /// FindLineNumber - Find the line number for the specified location in the - /// specified file. This is not a fast method. - unsigned FindLineNumber(TGLoc Loc, int BufferID = -1) const; - - - /// PrintError - Emit an error message about the specified location with the - /// specified string. - void PrintError(TGLoc ErrorLoc, const std::string &Msg) const; - -private: - void PrintIncludeStack(TGLoc IncludeLoc) const; -}; - -} // end llvm namespace - -#endif From sabre at nondot.org Sat Jun 20 22:39:35 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 03:39:35 -0000 Subject: [llvm-commits] [llvm] r73843 - in /llvm/trunk: include/llvm/Support/SourceMgr.h lib/Support/SourceMgr.cpp utils/TableGen/Record.h utils/TableGen/TGLexer.cpp utils/TableGen/TGLexer.h utils/TableGen/TGParser.cpp utils/TableGen/TGParser.h utils/TableGen/TableGen.cpp Message-ID: <200906210339.n5L3dakV025948@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 22:39:35 2009 New Revision: 73843 URL: http://llvm.org/viewvc/llvm-project?rev=73843&view=rev Log: rename TGLoc -> SMLoc. Modified: llvm/trunk/include/llvm/Support/SourceMgr.h llvm/trunk/lib/Support/SourceMgr.cpp llvm/trunk/utils/TableGen/Record.h llvm/trunk/utils/TableGen/TGLexer.cpp llvm/trunk/utils/TableGen/TGLexer.h llvm/trunk/utils/TableGen/TGParser.cpp llvm/trunk/utils/TableGen/TGParser.h llvm/trunk/utils/TableGen/TableGen.cpp Modified: llvm/trunk/include/llvm/Support/SourceMgr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SourceMgr.h?rev=73843&r1=73842&r2=73843&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/SourceMgr.h (original) +++ llvm/trunk/include/llvm/Support/SourceMgr.h Sat Jun 20 22:39:35 2009 @@ -24,19 +24,19 @@ class MemoryBuffer; class TGSourceMgr; -class TGLoc { +class SMLoc { const char *Ptr; public: - TGLoc() : Ptr(0) {} - TGLoc(const TGLoc &RHS) : Ptr(RHS.Ptr) {} + SMLoc() : Ptr(0) {} + SMLoc(const SMLoc &RHS) : Ptr(RHS.Ptr) {} - bool operator==(const TGLoc &RHS) const { return RHS.Ptr == Ptr; } - bool operator!=(const TGLoc &RHS) const { return RHS.Ptr != Ptr; } + bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; } + bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; } const char *getPointer() const { return Ptr; } - static TGLoc getFromPointer(const char *Ptr) { - TGLoc L; + static SMLoc getFromPointer(const char *Ptr) { + SMLoc L; L.Ptr = Ptr; return L; } @@ -51,7 +51,7 @@ /// IncludeLoc - This is the location of the parent include, or null if at /// the top level. - TGLoc IncludeLoc; + SMLoc IncludeLoc; }; /// Buffers - This is all of the buffers that we are reading from. @@ -73,12 +73,12 @@ return Buffers[i].Buffer; } - TGLoc getParentIncludeLoc(unsigned i) const { + SMLoc getParentIncludeLoc(unsigned i) const { assert(i < Buffers.size() && "Invalid Buffer ID!"); return Buffers[i].IncludeLoc; } - unsigned AddNewSourceBuffer(MemoryBuffer *F, TGLoc IncludeLoc) { + unsigned AddNewSourceBuffer(MemoryBuffer *F, SMLoc IncludeLoc) { SrcBuffer NB; NB.Buffer = F; NB.IncludeLoc = IncludeLoc; @@ -88,19 +88,19 @@ /// FindBufferContainingLoc - Return the ID of the buffer containing the /// specified location, returning -1 if not found. - int FindBufferContainingLoc(TGLoc Loc) const; + int FindBufferContainingLoc(SMLoc Loc) const; /// FindLineNumber - Find the line number for the specified location in the /// specified file. This is not a fast method. - unsigned FindLineNumber(TGLoc Loc, int BufferID = -1) const; + unsigned FindLineNumber(SMLoc Loc, int BufferID = -1) const; /// PrintError - Emit an error message about the specified location with the /// specified string. - void PrintError(TGLoc ErrorLoc, const std::string &Msg) const; + void PrintError(SMLoc ErrorLoc, const std::string &Msg) const; private: - void PrintIncludeStack(TGLoc IncludeLoc) const; + void PrintIncludeStack(SMLoc IncludeLoc) const; }; } // end llvm namespace Modified: llvm/trunk/lib/Support/SourceMgr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SourceMgr.cpp?rev=73843&r1=73842&r2=73843&view=diff ============================================================================== --- llvm/trunk/lib/Support/SourceMgr.cpp (original) +++ llvm/trunk/lib/Support/SourceMgr.cpp Sat Jun 20 22:39:35 2009 @@ -27,7 +27,7 @@ /// FindBufferContainingLoc - Return the ID of the buffer containing the /// specified location, returning -1 if not found. -int TGSourceMgr::FindBufferContainingLoc(TGLoc Loc) const { +int TGSourceMgr::FindBufferContainingLoc(SMLoc Loc) const { for (unsigned i = 0, e = Buffers.size(); i != e; ++i) if (Loc.getPointer() >= Buffers[i].Buffer->getBufferStart() && // Use <= here so that a pointer to the null at the end of the buffer @@ -39,7 +39,7 @@ /// FindLineNumber - Find the line number for the specified location in the /// specified file. This is not a fast method. -unsigned TGSourceMgr::FindLineNumber(TGLoc Loc, int BufferID) const { +unsigned TGSourceMgr::FindLineNumber(SMLoc Loc, int BufferID) const { if (BufferID == -1) BufferID = FindBufferContainingLoc(Loc); assert(BufferID != -1 && "Invalid Location!"); @@ -51,13 +51,13 @@ const char *Ptr = Buff->getBufferStart(); - for (; TGLoc::getFromPointer(Ptr) != Loc; ++Ptr) + for (; SMLoc::getFromPointer(Ptr) != Loc; ++Ptr) if (*Ptr == '\n') ++LineNo; return LineNo; } -void TGSourceMgr::PrintIncludeStack(TGLoc IncludeLoc) const { - if (IncludeLoc == TGLoc()) return; // Top of stack. +void TGSourceMgr::PrintIncludeStack(SMLoc IncludeLoc) const { + if (IncludeLoc == SMLoc()) return; // Top of stack. int CurBuf = FindBufferContainingLoc(IncludeLoc); assert(CurBuf != -1 && "Invalid or unspecified location!"); @@ -70,7 +70,7 @@ } -void TGSourceMgr::PrintError(TGLoc ErrorLoc, const std::string &Msg) const { +void TGSourceMgr::PrintError(SMLoc ErrorLoc, const std::string &Msg) const { raw_ostream &OS = errs(); // First thing to do: find the current buffer containing the specified Modified: llvm/trunk/utils/TableGen/Record.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=73843&r1=73842&r2=73843&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/Record.h (original) +++ llvm/trunk/utils/TableGen/Record.h Sat Jun 20 22:39:35 2009 @@ -1214,19 +1214,19 @@ class Record { std::string Name; - TGLoc Loc; + SMLoc Loc; std::vector TemplateArgs; std::vector Values; std::vector SuperClasses; public: - explicit Record(const std::string &N, TGLoc loc) : Name(N), Loc(loc) {} + explicit Record(const std::string &N, SMLoc loc) : Name(N), Loc(loc) {} ~Record() {} const std::string &getName() const { return Name; } void setName(const std::string &Name); // Also updates RecordKeeper. - TGLoc getLoc() const { return Loc; } + SMLoc getLoc() const { return Loc; } const std::vector &getTemplateArgs() const { return TemplateArgs; @@ -1381,7 +1381,7 @@ void dump() const; - MultiClass(const std::string &Name, TGLoc Loc) : Rec(Name, Loc) {} + MultiClass(const std::string &Name, SMLoc Loc) : Rec(Name, Loc) {} }; class RecordKeeper { @@ -1461,12 +1461,12 @@ class TGError { - TGLoc Loc; + SMLoc Loc; std::string Message; public: - TGError(TGLoc loc, const std::string &message) : Loc(loc), Message(message) {} + TGError(SMLoc loc, const std::string &message) : Loc(loc), Message(message) {} - TGLoc getLoc() const { return Loc; } + SMLoc getLoc() const { return Loc; } const std::string &getMessage() const { return Message; } }; @@ -1475,7 +1475,7 @@ extern RecordKeeper Records; -void PrintError(TGLoc ErrorLoc, const std::string &Msg); +void PrintError(SMLoc ErrorLoc, const std::string &Msg); } // End llvm namespace Modified: llvm/trunk/utils/TableGen/TGLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.cpp?rev=73843&r1=73842&r2=73843&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGLexer.cpp (original) +++ llvm/trunk/utils/TableGen/TGLexer.cpp Sat Jun 20 22:39:35 2009 @@ -31,8 +31,8 @@ TokStart = 0; } -TGLoc TGLexer::getLoc() const { - return TGLoc::getFromPointer(TokStart); +SMLoc TGLexer::getLoc() const { + return SMLoc::getFromPointer(TokStart); } @@ -45,10 +45,10 @@ void TGLexer::PrintError(const char *Loc, const std::string &Msg) const { - SrcMgr.PrintError(TGLoc::getFromPointer(Loc), Msg); + SrcMgr.PrintError(SMLoc::getFromPointer(Loc), Msg); } -void TGLexer::PrintError(TGLoc Loc, const std::string &Msg) const { +void TGLexer::PrintError(SMLoc Loc, const std::string &Msg) const { SrcMgr.PrintError(Loc, Msg); } @@ -66,8 +66,8 @@ // If this is the end of an included file, pop the parent file off the // include stack. - TGLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer); - if (ParentIncludeLoc != TGLoc()) { + SMLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer); + if (ParentIncludeLoc != SMLoc()) { CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc); CurBuf = SrcMgr.getMemoryBuffer(CurBuffer); CurPtr = ParentIncludeLoc.getPointer(); @@ -293,7 +293,7 @@ } // Save the line number and lex buffer of the includer. - CurBuffer = SrcMgr.AddNewSourceBuffer(NewBuf, TGLoc::getFromPointer(CurPtr)); + CurBuffer = SrcMgr.AddNewSourceBuffer(NewBuf, SMLoc::getFromPointer(CurPtr)); CurBuf = NewBuf; CurPtr = CurBuf->getBufferStart(); Modified: llvm/trunk/utils/TableGen/TGLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.h?rev=73843&r1=73842&r2=73843&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGLexer.h (original) +++ llvm/trunk/utils/TableGen/TGLexer.h Sat Jun 20 22:39:35 2009 @@ -23,7 +23,7 @@ namespace llvm { class MemoryBuffer; class TGSourceMgr; -class TGLoc; +class SMLoc; namespace tgtok { enum TokKind { @@ -101,10 +101,10 @@ return CurIntVal; } - TGLoc getLoc() const; + SMLoc getLoc() const; void PrintError(const char *Loc, const std::string &Msg) const; - void PrintError(TGLoc Loc, const std::string &Msg) const; + void PrintError(SMLoc Loc, const std::string &Msg) const; private: /// LexToken - Read the next token and return its code. Modified: llvm/trunk/utils/TableGen/TGParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=73843&r1=73842&r2=73843&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.cpp (original) +++ llvm/trunk/utils/TableGen/TGParser.cpp Sat Jun 20 22:39:35 2009 @@ -26,7 +26,7 @@ namespace llvm { struct SubClassReference { - TGLoc RefLoc; + SMLoc RefLoc; Record *Rec; std::vector TemplateArgs; SubClassReference() : Rec(0) {} @@ -35,7 +35,7 @@ }; struct SubMultiClassReference { - TGLoc RefLoc; + SMLoc RefLoc; MultiClass *MC; std::vector TemplateArgs; SubMultiClassReference() : MC(0) {} @@ -60,7 +60,7 @@ } // end namespace llvm -bool TGParser::AddValue(Record *CurRec, TGLoc Loc, const RecordVal &RV) { +bool TGParser::AddValue(Record *CurRec, SMLoc Loc, const RecordVal &RV) { if (CurRec == 0) CurRec = &CurMultiClass->Rec; @@ -79,7 +79,7 @@ /// SetValue - /// Return true on error, false on success. -bool TGParser::SetValue(Record *CurRec, TGLoc Loc, const std::string &ValName, +bool TGParser::SetValue(Record *CurRec, SMLoc Loc, const std::string &ValName, const std::vector &BitList, Init *V) { if (!V) return false; @@ -527,7 +527,7 @@ if (Lex.getCode() != tgtok::less) return false; - TGLoc StartLoc = Lex.getLoc(); + SMLoc StartLoc = Lex.getLoc(); Lex.Lex(); // eat the '<' // Parse the range list. @@ -549,7 +549,7 @@ if (Lex.getCode() != tgtok::l_brace) return false; - TGLoc StartLoc = Lex.getLoc(); + SMLoc StartLoc = Lex.getLoc(); Lex.Lex(); // eat the '{' // Parse the range list. @@ -634,7 +634,7 @@ Init *TGParser::ParseIDValue(Record *CurRec) { assert(Lex.getCode() == tgtok::Id && "Expected ID in ParseIDValue"); std::string Name = Lex.getCurStrVal(); - TGLoc Loc = Lex.getLoc(); + SMLoc Loc = Lex.getLoc(); Lex.Lex(); return ParseIDValue(CurRec, Name, Loc); } @@ -642,7 +642,7 @@ /// ParseIDValue - This is just like ParseIDValue above, but it assumes the ID /// has already been read. Init *TGParser::ParseIDValue(Record *CurRec, - const std::string &Name, TGLoc NameLoc) { + const std::string &Name, SMLoc NameLoc) { if (CurRec) { if (const RecordVal *RV = CurRec->getValue(Name)) return new VarInit(Name, RV->getType()); @@ -1041,7 +1041,7 @@ R = new CodeInit(Lex.getCurStrVal()); Lex.Lex(); break; case tgtok::question: R = new UnsetInit(); Lex.Lex(); break; case tgtok::Id: { - TGLoc NameLoc = Lex.getLoc(); + SMLoc NameLoc = Lex.getLoc(); std::string Name = Lex.getCurStrVal(); if (Lex.Lex() != tgtok::less) // consume the Id. return ParseIDValue(CurRec, Name, NameLoc); // Value ::= IDValue @@ -1087,7 +1087,7 @@ return new DefInit(NewRec); } case tgtok::l_brace: { // Value ::= '{' ValueList '}' - TGLoc BraceLoc = Lex.getLoc(); + SMLoc BraceLoc = Lex.getLoc(); Lex.Lex(); // eat the '{' std::vector Vals; @@ -1295,7 +1295,7 @@ switch (Lex.getCode()) { default: return Result; case tgtok::l_brace: { - TGLoc CurlyLoc = Lex.getLoc(); + SMLoc CurlyLoc = Lex.getLoc(); Lex.Lex(); // eat the '{' std::vector Ranges = ParseRangeList(); if (Ranges.empty()) return 0; @@ -1317,7 +1317,7 @@ break; } case tgtok::l_square: { - TGLoc SquareLoc = Lex.getLoc(); + SMLoc SquareLoc = Lex.getLoc(); Lex.Lex(); // eat the '[' std::vector Ranges = ParseRangeList(); if (Ranges.empty()) return 0; @@ -1449,7 +1449,7 @@ return ""; } - TGLoc IdLoc = Lex.getLoc(); + SMLoc IdLoc = Lex.getLoc(); std::string DeclName = Lex.getCurStrVal(); Lex.Lex(); @@ -1470,7 +1470,7 @@ // If a value is present, parse it. if (Lex.getCode() == tgtok::equal) { Lex.Lex(); - TGLoc ValLoc = Lex.getLoc(); + SMLoc ValLoc = Lex.getLoc(); Init *Val = ParseValue(CurRec, Type); if (Val == 0 || SetValue(CurRec, ValLoc, DeclName, std::vector(), Val)) @@ -1536,7 +1536,7 @@ if (Lex.Lex() != tgtok::Id) return TokError("expected field identifier after let"); - TGLoc IdLoc = Lex.getLoc(); + SMLoc IdLoc = Lex.getLoc(); std::string FieldName = Lex.getCurStrVal(); Lex.Lex(); // eat the field name. @@ -1640,7 +1640,7 @@ /// DefInst ::= DEF ObjectName ObjectBody /// llvm::Record *TGParser::ParseDef(MultiClass *CurMultiClass) { - TGLoc DefLoc = Lex.getLoc(); + SMLoc DefLoc = Lex.getLoc(); assert(Lex.getCode() == tgtok::Def && "Unknown tok"); Lex.Lex(); // Eat the 'def' token. @@ -1728,7 +1728,7 @@ return std::vector(); } std::string Name = Lex.getCurStrVal(); - TGLoc NameLoc = Lex.getLoc(); + SMLoc NameLoc = Lex.getLoc(); Lex.Lex(); // Eat the identifier. // Check for an optional RangeList. @@ -1780,7 +1780,7 @@ if (ParseObject()) return true; } else { // Object ::= LETCommand '{' ObjectList '}' - TGLoc BraceLoc = Lex.getLoc(); + SMLoc BraceLoc = Lex.getLoc(); // Otherwise, this is a group let. Lex.Lex(); // eat the '{'. @@ -1905,7 +1905,7 @@ if (Lex.Lex() != tgtok::Id) // eat the defm. return TokError("expected identifier after defm"); - TGLoc DefmPrefixLoc = Lex.getLoc(); + SMLoc DefmPrefixLoc = Lex.getLoc(); std::string DefmPrefix = Lex.getCurStrVal(); if (Lex.Lex() != tgtok::colon) return TokError("expected ':' after defm identifier"); @@ -1913,7 +1913,7 @@ // eat the colon. Lex.Lex(); - TGLoc SubClassLoc = Lex.getLoc(); + SMLoc SubClassLoc = Lex.getLoc(); SubClassReference Ref = ParseSubClassReference(0, true); while (1) { Modified: llvm/trunk/utils/TableGen/TGParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.h?rev=73843&r1=73842&r2=73843&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.h (original) +++ llvm/trunk/utils/TableGen/TGParser.h Sat Jun 20 22:39:35 2009 @@ -31,9 +31,9 @@ std::string Name; std::vector Bits; Init *Value; - TGLoc Loc; + SMLoc Loc; LetRecord(const std::string &N, const std::vector &B, Init *V, - TGLoc L) + SMLoc L) : Name(N), Bits(B), Value(V), Loc(L) { } }; @@ -55,7 +55,7 @@ /// routines return true on error, or false on success. bool ParseFile(); - bool Error(TGLoc L, const std::string &Msg) const { + bool Error(SMLoc L, const std::string &Msg) const { Lex.PrintError(L, Msg); return true; } @@ -63,8 +63,8 @@ return Error(Lex.getLoc(), Msg); } private: // Semantic analysis methods. - bool AddValue(Record *TheRec, TGLoc Loc, const RecordVal &RV); - bool SetValue(Record *TheRec, TGLoc Loc, const std::string &ValName, + bool AddValue(Record *TheRec, SMLoc Loc, const RecordVal &RV); + bool SetValue(Record *TheRec, SMLoc Loc, const std::string &ValName, const std::vector &BitList, Init *V); bool AddSubClass(Record *Rec, SubClassReference &SubClass); bool AddSubMultiClass(MultiClass *CurMC, @@ -92,7 +92,7 @@ SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC); Init *ParseIDValue(Record *CurRec); - Init *ParseIDValue(Record *CurRec, const std::string &Name, TGLoc NameLoc); + Init *ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc); Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0); Init *ParseValue(Record *CurRec, RecTy *ItemType = 0); std::vector ParseValueList(Record *CurRec, Record *ArgsRec = 0, RecTy *EltTy = 0); Modified: llvm/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=73843&r1=73842&r2=73843&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TableGen.cpp (original) +++ llvm/trunk/utils/TableGen/TableGen.cpp Sat Jun 20 22:39:35 2009 @@ -126,7 +126,7 @@ static TGSourceMgr SrcMgr; -void llvm::PrintError(TGLoc ErrorLoc, const std::string &Msg) { +void llvm::PrintError(SMLoc ErrorLoc, const std::string &Msg) { SrcMgr.PrintError(ErrorLoc, Msg); } @@ -145,7 +145,7 @@ } // Tell SrcMgr about this buffer, which is what TGParser will pick up. - SrcMgr.AddNewSourceBuffer(F, TGLoc()); + SrcMgr.AddNewSourceBuffer(F, SMLoc()); TGParser Parser(SrcMgr); From sabre at nondot.org Sat Jun 20 22:41:51 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 03:41:51 -0000 Subject: [llvm-commits] [llvm] r73844 - in /llvm/trunk: include/llvm/Support/SourceMgr.h lib/Support/CMakeLists.txt lib/Support/SourceMgr.cpp utils/TableGen/CMakeLists.txt utils/TableGen/TGLexer.cpp utils/TableGen/TGLexer.h utils/TableGen/TGParser.h utils/TableGen/TableGen.cpp Message-ID: <200906210341.n5L3fpgl026105@zion.cs.uiuc.edu> Author: lattner Date: Sat Jun 20 22:41:50 2009 New Revision: 73844 URL: http://llvm.org/viewvc/llvm-project?rev=73844&view=rev Log: Rename TGSourceMgr -> SourceMgr. Modified: llvm/trunk/include/llvm/Support/SourceMgr.h llvm/trunk/lib/Support/CMakeLists.txt llvm/trunk/lib/Support/SourceMgr.cpp llvm/trunk/utils/TableGen/CMakeLists.txt llvm/trunk/utils/TableGen/TGLexer.cpp llvm/trunk/utils/TableGen/TGLexer.h llvm/trunk/utils/TableGen/TGParser.h llvm/trunk/utils/TableGen/TableGen.cpp Modified: llvm/trunk/include/llvm/Support/SourceMgr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SourceMgr.h?rev=73844&r1=73843&r2=73844&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/SourceMgr.h (original) +++ llvm/trunk/include/llvm/Support/SourceMgr.h Sat Jun 20 22:41:50 2009 @@ -13,8 +13,8 @@ // //===----------------------------------------------------------------------===// -#ifndef TGSOURCEMGR_H -#define TGSOURCEMGR_H +#ifndef SUPPORT_SOURCEMGR_H +#define SUPPORT_SOURCEMGR_H #include #include @@ -22,7 +22,7 @@ namespace llvm { class MemoryBuffer; - class TGSourceMgr; + class SourceMgr; class SMLoc { const char *Ptr; @@ -42,9 +42,9 @@ } }; -/// TGSourceMgr - This owns the files read by tblgen, handles include stacks, +/// SourceMgr - This owns the files read by tblgen, handles include stacks, /// and handles printing of diagnostics. -class TGSourceMgr { +class SourceMgr { struct SrcBuffer { /// Buffer - The memory buffer for the file. MemoryBuffer *Buffer; @@ -57,11 +57,11 @@ /// Buffers - This is all of the buffers that we are reading from. std::vector Buffers; - TGSourceMgr(const TGSourceMgr&); // DO NOT IMPLEMENT - void operator=(const TGSourceMgr&); // DO NOT IMPLEMENT + SourceMgr(const SourceMgr&); // DO NOT IMPLEMENT + void operator=(const SourceMgr&); // DO NOT IMPLEMENT public: - TGSourceMgr() {} - ~TGSourceMgr(); + SourceMgr() {} + ~SourceMgr(); const SrcBuffer &getBufferInfo(unsigned i) const { assert(i < Buffers.size() && "Invalid Buffer ID!"); Modified: llvm/trunk/lib/Support/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=73844&r1=73843&r2=73844&view=diff ============================================================================== --- llvm/trunk/lib/Support/CMakeLists.txt (original) +++ llvm/trunk/lib/Support/CMakeLists.txt Sat Jun 20 22:41:50 2009 @@ -19,6 +19,7 @@ PrettyStackTrace.cpp SlowOperationInformer.cpp SmallPtrSet.cpp + SourceMgr.cpp Statistic.cpp Streams.cpp StringExtras.cpp Modified: llvm/trunk/lib/Support/SourceMgr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SourceMgr.cpp?rev=73844&r1=73843&r2=73844&view=diff ============================================================================== --- llvm/trunk/lib/Support/SourceMgr.cpp (original) +++ llvm/trunk/lib/Support/SourceMgr.cpp Sat Jun 20 22:41:50 2009 @@ -18,7 +18,7 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; -TGSourceMgr::~TGSourceMgr() { +SourceMgr::~SourceMgr() { while (!Buffers.empty()) { delete Buffers.back().Buffer; Buffers.pop_back(); @@ -27,7 +27,7 @@ /// FindBufferContainingLoc - Return the ID of the buffer containing the /// specified location, returning -1 if not found. -int TGSourceMgr::FindBufferContainingLoc(SMLoc Loc) const { +int SourceMgr::FindBufferContainingLoc(SMLoc Loc) const { for (unsigned i = 0, e = Buffers.size(); i != e; ++i) if (Loc.getPointer() >= Buffers[i].Buffer->getBufferStart() && // Use <= here so that a pointer to the null at the end of the buffer @@ -39,7 +39,7 @@ /// FindLineNumber - Find the line number for the specified location in the /// specified file. This is not a fast method. -unsigned TGSourceMgr::FindLineNumber(SMLoc Loc, int BufferID) const { +unsigned SourceMgr::FindLineNumber(SMLoc Loc, int BufferID) const { if (BufferID == -1) BufferID = FindBufferContainingLoc(Loc); assert(BufferID != -1 && "Invalid Location!"); @@ -56,7 +56,7 @@ return LineNo; } -void TGSourceMgr::PrintIncludeStack(SMLoc IncludeLoc) const { +void SourceMgr::PrintIncludeStack(SMLoc IncludeLoc) const { if (IncludeLoc == SMLoc()) return; // Top of stack. int CurBuf = FindBufferContainingLoc(IncludeLoc); @@ -70,7 +70,7 @@ } -void TGSourceMgr::PrintError(SMLoc ErrorLoc, const std::string &Msg) const { +void SourceMgr::PrintError(SMLoc ErrorLoc, const std::string &Msg) const { raw_ostream &OS = errs(); // First thing to do: find the current buffer containing the specified Modified: llvm/trunk/utils/TableGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CMakeLists.txt?rev=73844&r1=73843&r2=73844&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CMakeLists.txt (original) +++ llvm/trunk/utils/TableGen/CMakeLists.txt Sat Jun 20 22:41:50 2009 @@ -17,7 +17,6 @@ SubtargetEmitter.cpp TGLexer.cpp TGParser.cpp - TGSourceMgr.cpp TGValueTypes.cpp TableGen.cpp TableGenBackend.cpp Modified: llvm/trunk/utils/TableGen/TGLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.cpp?rev=73844&r1=73843&r2=73844&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGLexer.cpp (original) +++ llvm/trunk/utils/TableGen/TGLexer.cpp Sat Jun 20 22:41:50 2009 @@ -24,7 +24,7 @@ #include using namespace llvm; -TGLexer::TGLexer(TGSourceMgr &SM) : SrcMgr(SM) { +TGLexer::TGLexer(SourceMgr &SM) : SrcMgr(SM) { CurBuffer = 0; CurBuf = SrcMgr.getMemoryBuffer(CurBuffer); CurPtr = CurBuf->getBufferStart(); Modified: llvm/trunk/utils/TableGen/TGLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.h?rev=73844&r1=73843&r2=73844&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGLexer.h (original) +++ llvm/trunk/utils/TableGen/TGLexer.h Sat Jun 20 22:41:50 2009 @@ -22,7 +22,7 @@ namespace llvm { class MemoryBuffer; -class TGSourceMgr; +class SourceMgr; class SMLoc; namespace tgtok { @@ -58,7 +58,7 @@ /// TGLexer - TableGen Lexer class. class TGLexer { - TGSourceMgr &SrcMgr; + SourceMgr &SrcMgr; const char *CurPtr; const MemoryBuffer *CurBuf; @@ -77,7 +77,7 @@ // include files in. std::vector IncludeDirectories; public: - TGLexer(TGSourceMgr &SrcMgr); + TGLexer(SourceMgr &SrcMgr); ~TGLexer() {} void setIncludeDirs(const std::vector &Dirs) { Modified: llvm/trunk/utils/TableGen/TGParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.h?rev=73844&r1=73843&r2=73844&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.h (original) +++ llvm/trunk/utils/TableGen/TGParser.h Sat Jun 20 22:41:50 2009 @@ -47,7 +47,7 @@ /// current value. MultiClass *CurMultiClass; public: - TGParser(TGSourceMgr &SrcMgr) : Lex(SrcMgr), CurMultiClass(0) {} + TGParser(SourceMgr &SrcMgr) : Lex(SrcMgr), CurMultiClass(0) {} void setIncludeDirs(const std::vector &D){Lex.setIncludeDirs(D);} Modified: llvm/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=73844&r1=73843&r2=73844&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TableGen.cpp (original) +++ llvm/trunk/utils/TableGen/TableGen.cpp Sat Jun 20 22:41:50 2009 @@ -124,7 +124,7 @@ // FIXME: Eliminate globals from tblgen. RecordKeeper llvm::Records; -static TGSourceMgr SrcMgr; +static SourceMgr SrcMgr; void llvm::PrintError(SMLoc ErrorLoc, const std::string &Msg) { SrcMgr.PrintError(ErrorLoc, Msg); @@ -136,7 +136,7 @@ /// file. static bool ParseFile(const std::string &Filename, const std::vector &IncludeDirs, - TGSourceMgr &SrcMgr) { + SourceMgr &SrcMgr) { std::string ErrorStr; MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr); if (F == 0) { From sabre at nondot.org Sun Jun 21 00:06:05 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 05:06:05 -0000 Subject: [llvm-commits] [llvm] r73845 - in /llvm/trunk: include/llvm/Support/SourceMgr.h lib/Support/SourceMgr.cpp utils/TableGen/TGLexer.cpp utils/TableGen/TGLexer.h utils/TableGen/TGParser.h utils/TableGen/TableGen.cpp Message-ID: <200906210506.n5L565R9028973@zion.cs.uiuc.edu> Author: lattner Date: Sun Jun 21 00:06:04 2009 New Revision: 73845 URL: http://llvm.org/viewvc/llvm-project?rev=73845&view=rev Log: move include searching logic from TGLexer to SourceMgr. Modified: llvm/trunk/include/llvm/Support/SourceMgr.h llvm/trunk/lib/Support/SourceMgr.cpp llvm/trunk/utils/TableGen/TGLexer.cpp llvm/trunk/utils/TableGen/TGLexer.h llvm/trunk/utils/TableGen/TGParser.h llvm/trunk/utils/TableGen/TableGen.cpp Modified: llvm/trunk/include/llvm/Support/SourceMgr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SourceMgr.h?rev=73845&r1=73844&r2=73845&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/SourceMgr.h (original) +++ llvm/trunk/include/llvm/Support/SourceMgr.h Sun Jun 21 00:06:04 2009 @@ -57,12 +57,20 @@ /// Buffers - This is all of the buffers that we are reading from. std::vector Buffers; + // IncludeDirectories - This is the list of directories we should search for + // include files in. + std::vector IncludeDirectories; + SourceMgr(const SourceMgr&); // DO NOT IMPLEMENT void operator=(const SourceMgr&); // DO NOT IMPLEMENT public: SourceMgr() {} ~SourceMgr(); + void setIncludeDirs(const std::vector &Dirs) { + IncludeDirectories = Dirs; + } + const SrcBuffer &getBufferInfo(unsigned i) const { assert(i < Buffers.size() && "Invalid Buffer ID!"); return Buffers[i]; @@ -86,6 +94,11 @@ return Buffers.size()-1; } + /// AddIncludeFile - Search for a file with the specified name in the current + /// directory or in one of the IncludeDirs. If no file is found, this returns + /// ~0, otherwise it returns the buffer ID of the stacked file. + unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc); + /// FindBufferContainingLoc - Return the ID of the buffer containing the /// specified location, returning -1 if not found. int FindBufferContainingLoc(SMLoc Loc) const; Modified: llvm/trunk/lib/Support/SourceMgr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SourceMgr.cpp?rev=73845&r1=73844&r2=73845&view=diff ============================================================================== --- llvm/trunk/lib/Support/SourceMgr.cpp (original) +++ llvm/trunk/lib/Support/SourceMgr.cpp Sun Jun 21 00:06:04 2009 @@ -25,6 +25,26 @@ } } +/// AddIncludeFile - Search for a file with the specified name in the current +/// directory or in one of the IncludeDirs. If no file is found, this returns +/// ~0, otherwise it returns the buffer ID of the stacked file. +unsigned SourceMgr::AddIncludeFile(const std::string &Filename, + SMLoc IncludeLoc) { + + MemoryBuffer *NewBuf = MemoryBuffer::getFile(Filename.c_str()); + + // If the file didn't exist directly, see if it's in an include path. + for (unsigned i = 0, e = IncludeDirectories.size(); i != e && !NewBuf; ++i) { + std::string IncFile = IncludeDirectories[i] + "/" + Filename; + NewBuf = MemoryBuffer::getFile(IncFile.c_str()); + } + + if (NewBuf == 0) return ~0U; + + return AddNewSourceBuffer(NewBuf, IncludeLoc); +} + + /// FindBufferContainingLoc - Return the ID of the buffer containing the /// specified location, returning -1 if not found. int SourceMgr::FindBufferContainingLoc(SMLoc Loc) const { Modified: llvm/trunk/utils/TableGen/TGLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.cpp?rev=73845&r1=73844&r2=73845&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGLexer.cpp (original) +++ llvm/trunk/utils/TableGen/TGLexer.cpp Sun Jun 21 00:06:04 2009 @@ -278,24 +278,15 @@ // Get the string. std::string Filename = CurStrVal; - // Try to find the file. - MemoryBuffer *NewBuf = MemoryBuffer::getFile(Filename.c_str()); - - // If the file didn't exist directly, see if it's in an include path. - for (unsigned i = 0, e = IncludeDirectories.size(); i != e && !NewBuf; ++i) { - std::string IncFile = IncludeDirectories[i] + "/" + Filename; - NewBuf = MemoryBuffer::getFile(IncFile.c_str()); - } - - if (NewBuf == 0) { + + CurBuffer = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr)); + if (CurBuffer == ~0U) { PrintError(getLoc(), "Could not find include file '" + Filename + "'"); return true; } // Save the line number and lex buffer of the includer. - CurBuffer = SrcMgr.AddNewSourceBuffer(NewBuf, SMLoc::getFromPointer(CurPtr)); - - CurBuf = NewBuf; + CurBuf = SrcMgr.getMemoryBuffer(CurBuffer); CurPtr = CurBuf->getBufferStart(); return false; } Modified: llvm/trunk/utils/TableGen/TGLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.h?rev=73845&r1=73844&r2=73845&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGLexer.h (original) +++ llvm/trunk/utils/TableGen/TGLexer.h Sun Jun 21 00:06:04 2009 @@ -73,17 +73,10 @@ /// by the SourceMgr object. int CurBuffer; - // IncludeDirectories - This is the list of directories we should search for - // include files in. - std::vector IncludeDirectories; public: TGLexer(SourceMgr &SrcMgr); ~TGLexer() {} - void setIncludeDirs(const std::vector &Dirs) { - IncludeDirectories = Dirs; - } - tgtok::TokKind Lex() { return CurCode = LexToken(); } Modified: llvm/trunk/utils/TableGen/TGParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.h?rev=73845&r1=73844&r2=73845&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.h (original) +++ llvm/trunk/utils/TableGen/TGParser.h Sun Jun 21 00:06:04 2009 @@ -49,8 +49,6 @@ public: TGParser(SourceMgr &SrcMgr) : Lex(SrcMgr), CurMultiClass(0) {} - void setIncludeDirs(const std::vector &D){Lex.setIncludeDirs(D);} - /// ParseFile - Main entrypoint for parsing a tblgen file. These parser /// routines return true on error, or false on success. bool ParseFile(); Modified: llvm/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=73845&r1=73844&r2=73845&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TableGen.cpp (original) +++ llvm/trunk/utils/TableGen/TableGen.cpp Sun Jun 21 00:06:04 2009 @@ -146,12 +146,12 @@ // Tell SrcMgr about this buffer, which is what TGParser will pick up. SrcMgr.AddNewSourceBuffer(F, SMLoc()); - - TGParser Parser(SrcMgr); // Record the location of the include directory so that the lexer can find // it later. - Parser.setIncludeDirs(IncludeDirs); + SrcMgr.setIncludeDirs(IncludeDirs); + + TGParser Parser(SrcMgr); return Parser.ParseFile(); } From sabre at nondot.org Sun Jun 21 00:22:38 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 05:22:38 -0000 Subject: [llvm-commits] [llvm] r73846 - /llvm/trunk/tools/llvm-mc/llvm-mc.cpp Message-ID: <200906210522.n5L5Mcu1029427@zion.cs.uiuc.edu> Author: lattner Date: Sun Jun 21 00:22:37 2009 New Revision: 73846 URL: http://llvm.org/viewvc/llvm-project?rev=73846&view=rev Log: start wiring up support for asm parsing. Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp 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=73846&r1=73845&r2=73846&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original) +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Sun Jun 21 00:22:37 2009 @@ -16,6 +16,7 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Signals.h" using namespace llvm; @@ -27,31 +28,63 @@ OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename")); -int main(int argc, char **argv) { - // Print a stack trace if we signal out. - sys::PrintStackTraceOnErrorSignal(); - PrettyStackTraceProgram X(argc, argv); - - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. - - cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n"); +static cl::list +IncludeDirs("I", cl::desc("Directory of include files"), + cl::value_desc("directory"), cl::Prefix); + +enum ActionType { + AC_Assemble +}; + +static cl::opt +Action(cl::desc("Action to perform:"), + cl::values(clEnumValN(AC_Assemble, "assemble", + "Assemble a .s file (default)"), + clEnumValEnd)); +static int AssembleInput(const char *ProgName) { std::string ErrorMessage; - - MemoryBuffer *Buffer - = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage); - + MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename, + &ErrorMessage); if (Buffer == 0) { - errs() << argv[0] << ": "; + errs() << ProgName << ": "; if (ErrorMessage.size()) errs() << ErrorMessage << "\n"; else errs() << "input file didn't read correctly.\n"; return 1; } + + SourceMgr SrcMgr; + + // Tell SrcMgr about this buffer, which is what TGParser will pick up. + SrcMgr.AddNewSourceBuffer(Buffer, SMLoc()); + + // Record the location of the include directories so that the lexer can find + // it later. + SrcMgr.setIncludeDirs(IncludeDirs); + //TGParser Parser(SrcMgr); + //return Parser.ParseFile(); + return 1; +} + + +int main(int argc, char **argv) { + // Print a stack trace if we signal out. + sys::PrintStackTraceOnErrorSignal(); + PrettyStackTraceProgram X(argc, argv); + llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. + cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n"); + + switch (Action) { + default: + case AC_Assemble: + return AssembleInput(argv[0]); + } + return 0; } From sabre at nondot.org Sun Jun 21 00:33:06 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 05:33:06 -0000 Subject: [llvm-commits] [llvm] r73847 - in /llvm/trunk/utils/TableGen: TGLexer.cpp TGLexer.h Message-ID: <200906210533.n5L5X6vv029735@zion.cs.uiuc.edu> Author: lattner Date: Sun Jun 21 00:33:06 2009 New Revision: 73847 URL: http://llvm.org/viewvc/llvm-project?rev=73847&view=rev Log: prune #include, fix warning. Modified: llvm/trunk/utils/TableGen/TGLexer.cpp llvm/trunk/utils/TableGen/TGLexer.h Modified: llvm/trunk/utils/TableGen/TGLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.cpp?rev=73847&r1=73846&r2=73847&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGLexer.cpp (original) +++ llvm/trunk/utils/TableGen/TGLexer.cpp Sun Jun 21 00:33:06 2009 @@ -280,7 +280,7 @@ CurBuffer = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr)); - if (CurBuffer == ~0U) { + if (CurBuffer == -1) { PrintError(getLoc(), "Could not find include file '" + Filename + "'"); return true; } Modified: llvm/trunk/utils/TableGen/TGLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.h?rev=73847&r1=73846&r2=73847&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGLexer.h (original) +++ llvm/trunk/utils/TableGen/TGLexer.h Sun Jun 21 00:33:06 2009 @@ -17,7 +17,6 @@ #include "llvm/Support/DataTypes.h" #include #include -#include #include namespace llvm { From sabre at nondot.org Sun Jun 21 02:19:10 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 07:19:10 -0000 Subject: [llvm-commits] [llvm] r73848 - in /llvm/trunk/tools/llvm-mc: AsmLexer.cpp AsmLexer.h llvm-mc.cpp Message-ID: <200906210719.n5L7JAoJ032572@zion.cs.uiuc.edu> Author: lattner Date: Sun Jun 21 02:19:10 2009 New Revision: 73848 URL: http://llvm.org/viewvc/llvm-project?rev=73848&view=rev Log: some baby steps. Added: llvm/trunk/tools/llvm-mc/AsmLexer.cpp llvm/trunk/tools/llvm-mc/AsmLexer.h Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp Added: llvm/trunk/tools/llvm-mc/AsmLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.cpp?rev=73848&view=auto ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmLexer.cpp (added) +++ llvm/trunk/tools/llvm-mc/AsmLexer.cpp Sun Jun 21 02:19:10 2009 @@ -0,0 +1,87 @@ +//===- AsmLexer.cpp - Lexer for Assembly Files ----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This class implements the lexer for assembly files. +// +//===----------------------------------------------------------------------===// + +#include "AsmLexer.h" +#include "llvm/Support/SourceMgr.h" +#include "llvm/Support/MemoryBuffer.h" +using namespace llvm; + +AsmLexer::AsmLexer(SourceMgr &SM) : SrcMgr(SM) { + CurBuffer = 0; + CurBuf = SrcMgr.getMemoryBuffer(CurBuffer); + CurPtr = CurBuf->getBufferStart(); + TokStart = 0; +} + +void AsmLexer::PrintError(const char *Loc, const std::string &Msg) const { + SrcMgr.PrintError(SMLoc::getFromPointer(Loc), Msg); +} + +void AsmLexer::PrintError(SMLoc Loc, const std::string &Msg) const { + SrcMgr.PrintError(Loc, Msg); +} + +int AsmLexer::getNextChar() { + char CurChar = *CurPtr++; + switch (CurChar) { + default: + return (unsigned char)CurChar; + case 0: { + // A nul character in the stream is either the end of the current buffer or + // a random nul in the file. Disambiguate that here. + if (CurPtr-1 != CurBuf->getBufferEnd()) + return 0; // Just whitespace. + + // If this is the end of an included file, pop the parent file off the + // include stack. + SMLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer); + if (ParentIncludeLoc != SMLoc()) { + CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc); + CurBuf = SrcMgr.getMemoryBuffer(CurBuffer); + CurPtr = ParentIncludeLoc.getPointer(); + return getNextChar(); + } + + // Otherwise, return end of file. + --CurPtr; // Another call to lex will return EOF again. + return EOF; + } + } +} + +asmtok::TokKind AsmLexer::LexToken() { + TokStart = CurPtr; + // This always consumes at least one character. + int CurChar = getNextChar(); + + switch (CurChar) { + default: + // Handle letters: [a-zA-Z_] +// if (isalpha(CurChar) || CurChar == '_' || CurChar == '#') +// return LexIdentifier(); + + // Unknown character, emit an error. + return asmtok::Error; + case EOF: return asmtok::Eof; + case 0: + case ' ': + case '\t': + case '\n': + case '\r': + // Ignore whitespace. + return LexToken(); + case ':': return asmtok::Colon; + case '+': return asmtok::Plus; + case '-': return asmtok::Minus; + } +} \ No newline at end of file Added: llvm/trunk/tools/llvm-mc/AsmLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.h?rev=73848&view=auto ============================================================================== --- llvm/trunk/tools/llvm-mc/AsmLexer.h (added) +++ llvm/trunk/tools/llvm-mc/AsmLexer.h Sun Jun 21 02:19:10 2009 @@ -0,0 +1,92 @@ +//===- AsmLexer.h - Lexer for Assembly Files --------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This class declares the lexer for assembly files. +// +//===----------------------------------------------------------------------===// + +#ifndef ASMLEXER_H +#define ASMLEXER_H + +#include "llvm/Support/DataTypes.h" +#include +#include + +namespace llvm { +class MemoryBuffer; +class SourceMgr; +class SMLoc; + +namespace asmtok { + enum TokKind { + // Markers + Eof, Error, + + Identifier, + IntVal, + + + Colon, + Plus, + Minus + }; +} + +/// AsmLexer - Lexer class for assembly files. +class AsmLexer { + SourceMgr &SrcMgr; + + const char *CurPtr; + const MemoryBuffer *CurBuf; + + // Information about the current token. + const char *TokStart; + asmtok::TokKind CurKind; + std::string CurStrVal; // This is valid for Identifier. + int64_t CurIntVal; + + /// CurBuffer - This is the current buffer index we're lexing from as managed + /// by the SourceMgr object. + int CurBuffer; + +public: + AsmLexer(SourceMgr &SrcMgr); + ~AsmLexer() {} + + asmtok::TokKind Lex() { + return CurKind = LexToken(); + } + + asmtok::TokKind getKind() const { return CurKind; } + + const std::string &getCurStrVal() const { + assert(CurKind == asmtok::Identifier && + "This token doesn't have a string value"); + return CurStrVal; + } + int64_t getCurIntVal() const { + assert(CurKind == asmtok::IntVal && "This token isn't an integer"); + return CurIntVal; + } + + SMLoc getLoc() const; + + void PrintError(const char *Loc, const std::string &Msg) const; + void PrintError(SMLoc Loc, const std::string &Msg) const; + +private: + int getNextChar(); + + /// LexToken - Read the next token and return its code. + asmtok::TokKind LexToken(); +}; + +} // end namespace llvm + +#endif 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=73848&r1=73847&r2=73848&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original) +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Sun Jun 21 02:19:10 2009 @@ -19,6 +19,7 @@ #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Signals.h" +#include "AsmLexer.h" using namespace llvm; static cl::opt @@ -63,10 +64,29 @@ // Record the location of the include directories so that the lexer can find // it later. SrcMgr.setIncludeDirs(IncludeDirs); + + - //TGParser Parser(SrcMgr); - //return Parser.ParseFile(); + AsmLexer Lexer(SrcMgr); + asmtok::TokKind Tok = Lexer.Lex(); + while (Tok != asmtok::Eof) { + switch (Tok) { + default: outs() << "<>\n"; break; + case asmtok::Error: outs() << "<>\n"; break; + case asmtok::Identifier: + outs() << "identifier: " << Lexer.getCurStrVal() << '\n'; + break; + case asmtok::IntVal: + outs() << "int: " << Lexer.getCurIntVal() << '\n'; + break; + case asmtok::Colon: outs() << "Colon\n"; break; + case asmtok::Plus: outs() << "Plus\n"; break; + case asmtok::Minus: outs() << "Minus\n"; break; + } + + Tok = Lexer.Lex(); + } return 1; } From sabre at nondot.org Sun Jun 21 02:19:34 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 21 Jun 2009 07:19:34 -0000 Subject: [llvm-commits] [llvm] r73849 - /llvm/trunk/tools/llvm-mc/CMakeLists.txt Message-ID: <200906210719.n5L7JYGx032614@zion.cs.uiuc.edu> Author: lattner Date: Sun Jun 21 02:19:34 2009 New Revision: 73849 URL: http://llvm.org/viewvc/llvm-project?rev=73849&view=rev Log: oh yeah, cmake needs to be told explicitly about new files :) Modified: llvm/trunk/tools/llvm-mc/CMakeLists.txt Modified: llvm/trunk/tools/llvm-mc/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/CMakeLists.txt?rev=73849&r1=73848&r2=73849&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/CMakeLists.txt (original) +++ llvm/trunk/tools/llvm-mc/CMakeLists.txt Sun Jun 21 02:19:34 2009 @@ -2,4 +2,5 @@ add_llvm_tool(llvm-mc llvm-mc.cpp + AsmLexer.cpp ) From rafael.espindola at gmail.com Sun Jun 21 07:02:56 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sun, 21 Jun 2009 12:02:56 -0000 Subject: [llvm-commits] [llvm] r73850 - in /llvm/trunk: lib/Target/X86/X86FloatingPoint.cpp test/CodeGen/X86/inline-asm-fpstack2.ll Message-ID: <200906211202.n5LC2vjO011942@zion.cs.uiuc.edu> Author: rafael Date: Sun Jun 21 07:02:51 2009 New Revision: 73850 URL: http://llvm.org/viewvc/llvm-project?rev=73850&view=rev Log: Fix PR4185. Handle FpSET_ST0_80 being used when ST0 is still alive. Added: llvm/trunk/test/CodeGen/X86/inline-asm-fpstack2.ll Modified: llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp Modified: llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp?rev=73850&r1=73849&r2=73850&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp Sun Jun 21 07:02:51 2009 @@ -991,8 +991,13 @@ case X86::FpSET_ST0_32: case X86::FpSET_ST0_64: case X86::FpSET_ST0_80: - assert((StackTop == 1 || StackTop == 2) - && "Stack should have one or two element on it to return!"); + // FpSET_ST0_80 is generated by copyRegToReg for both function return + // and inline assembly with