From baldrick at free.fr Mon May 4 02:00:47 2009
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 4 May 2009 09:00:47 +0200
Subject: [llvm-commits] [llvm] r70820 - in /llvm/trunk:
lib/Transforms/Scalar/JumpThreading.cpp
test/Transforms/JumpThreading/no-irreducible-loops.ll
In-Reply-To: <200905040228.n442S8tg027269@zion.cs.uiuc.edu>
References: <200905040228.n442S8tg027269@zion.cs.uiuc.edu>
Message-ID: <200905040900.50025.baldrick@free.fr>
Hi Chris,
> +/// FindLoopHeaders - We do not wan jump threading to turn proper loop
do not wan -> do not want
Ciao,
Duncan.
From baldrick at free.fr Mon May 4 02:05:18 2009
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 4 May 2009 09:05:18 +0200
Subject: [llvm-commits] [llvm-gcc-4.2] r70801 -
/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
In-Reply-To: <200905032136.n43LaNFN018015@zion.cs.uiuc.edu>
References: <200905032136.n43LaNFN018015@zion.cs.uiuc.edu>
Message-ID: <200905040905.18847.baldrick@free.fr>
Hi Bill,
> Don'e create debug info for ObjC metadata.
how about setting DECL_ARTIFICIAL for such globals, and then teach
the backend not to output debug info for globals with DECL_ARTIFICIAL
set?
/* Used to indicate that this DECL represents a compiler-generated entity. */
#define DECL_ARTIFICIAL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.artificial_flag)
Ciao,
Duncan.
>
> Modified:
> llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=70801&r1=70800&r2=70801&view=diff
>
> ==============================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Sun May 3 16:36:23 2009
> @@ -1390,8 +1390,15 @@
> // No debug info for globals when optimization is on. While this is
> // something that would be accurate and useful to a user, it currently
> // affects some optimizations that, e.g., count uses.
> - if (TheDebugInfo && !optimize)
> - TheDebugInfo->EmitGlobalVariable(GV, decl);
> + if (TheDebugInfo && !optimize) {
> + const char *Name = GV->getName().c_str();
> + const char LPrefix[] = "\01L_OBJC_";
> + const char lPrefix[] = "\01l_OBJC_";
> +
> + if (strncmp(Name, LPrefix, sizeof(LPrefix) - 1) != 0 &&
> + strncmp(Name, lPrefix, sizeof(lPrefix) - 1) != 0)
> + TheDebugInfo->EmitGlobalVariable(GV, decl);
> + }
>
> TREE_ASM_WRITTEN(decl) = 1;
> timevar_pop(TV_LLVM_GLOBALS);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
From kremenek at apple.com Mon May 4 02:13:49 2009
From: kremenek at apple.com (Ted Kremenek)
Date: Mon, 04 May 2009 07:13:49 -0000
Subject: [llvm-commits] [llvm] r70838 - /llvm/tags/checker/checker-0.193/
Message-ID: <200905040713.n447Dno3004098@zion.cs.uiuc.edu>
Author: kremenek
Date: Mon May 4 02:13:49 2009
New Revision: 70838
URL: http://llvm.org/viewvc/llvm-project?rev=70838&view=rev
Log:
Removing checker-0.193.
Removed:
llvm/tags/checker/checker-0.193/
From kremenek at apple.com Mon May 4 02:15:04 2009
From: kremenek at apple.com (Ted Kremenek)
Date: Mon, 04 May 2009 07:15:04 -0000
Subject: [llvm-commits] [llvm] r70840 - /llvm/tags/checker/checker-0.193/
Message-ID: <200905040715.n447F469004149@zion.cs.uiuc.edu>
Author: kremenek
Date: Mon May 4 02:15:04 2009
New Revision: 70840
URL: http://llvm.org/viewvc/llvm-project?rev=70840&view=rev
Log:
Tagging checker-0.193.
Added:
llvm/tags/checker/checker-0.193/
- copied from r70839, llvm/trunk/
From baldrick at free.fr Mon May 4 02:42:54 2009
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 4 May 2009 09:42:54 +0200
Subject: [llvm-commits] [llvm] r70790 - /llvm/trunk/docs/LangRef.html
In-Reply-To: <470D68BA-BCC1-4F82-9D78-426358B58E2E@nondot.org>
References: <200905031906.n43J60Bg012814@zion.cs.uiuc.edu>
<200905032206.29498.baldrick@free.fr>
<470D68BA-BCC1-4F82-9D78-426358B58E2E@nondot.org>
Message-ID: <200905040942.54978.baldrick@free.fr>
Hi Chris,
> >> throw
> >> is the empty set. :) Thanks to Fritz for pointing this out.
> >
> > what's wrong with a readonly function using unwind? I think
> > the use of unwind is orthogonal to readonly: it's what the
> > nounwind attribute is for. Of course a readonly function can't
> > call the C++ throw routine etc, but that's a different issue.
> > If you want readonly to mean: doesn't do anything annoying
> > (no side-effects), then the name should be changed, and the
> > function attributes taught to do loop analysis and not mark
> > a function readonly unless all loops are finite etc. I think
> > it is better to keep readonly and nounwind separate.
>
> I can definitely be convinced :), but my understanding is that the
> compiler currently deletes readonly/readnone calls if they are dead.
yes, this is a known bug :)
> We could change this to also require them to be nounwind, and change
> the C front-ends to have pure/const also add nounwind. What do you
> think?
That's my preferred solution. I had a look at isInstructionTriviallyDead
and was struck by the fact that it doesn't check isTrapping. Is it valid
to delete a divide by zero if the result has no uses? Currently this is
done. If so, is it valid to delete a readonly call even if it may throw
an exception?
Ciao,
Duncan.
From eli.friedman at gmail.com Mon May 4 03:31:43 2009
From: eli.friedman at gmail.com (Eli Friedman)
Date: Mon, 4 May 2009 01:31:43 -0700
Subject: [llvm-commits] [llvm] r70790 - /llvm/trunk/docs/LangRef.html
In-Reply-To: <200905040942.54978.baldrick@free.fr>
References: <200905031906.n43J60Bg012814@zion.cs.uiuc.edu>
<200905032206.29498.baldrick@free.fr>
<470D68BA-BCC1-4F82-9D78-426358B58E2E@nondot.org>
<200905040942.54978.baldrick@free.fr>
Message-ID:
On Mon, May 4, 2009 at 12:42 AM, Duncan Sands wrote:
> Is it valid
> to delete a divide by zero if the result has no uses?
Yes, it is valid; division by zero is undefined behavior, so it can do
anything; we make no attempt to preserve any traps from that. For
example, we optimize x/x to 1 (where x is an integer). Besides, even
if we did try to preserve the trap, depending on a trap isn't
portable; for example, the PowerPC division instruction never traps.
>?If so, is it valid to delete a readonly call even if it may throw
> an exception?
No, it is not valid; throwing an exception is well-defined behavior.
(Of course, assuming throwing an exception from a readonly call is
legal.)
-Eli
From edwintorok at gmail.com Mon May 4 03:49:05 2009
From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=)
Date: Mon, 04 May 2009 11:49:05 +0300
Subject: [llvm-commits] [llvm] r70790 - /llvm/trunk/docs/LangRef.html
In-Reply-To: <470D68BA-BCC1-4F82-9D78-426358B58E2E@nondot.org>
References: <200905031906.n43J60Bg012814@zion.cs.uiuc.edu> <200905032206.29498.baldrick@free.fr>
<470D68BA-BCC1-4F82-9D78-426358B58E2E@nondot.org>
Message-ID: <49FEAC01.4030708@gmail.com>
On 2009-05-03 23:11, Chris Lattner wrote:
> On May 3, 2009, at 1:06 PM, Duncan Sands wrote:
>
>
>> Hi Chris,
>>
>>
>>> Remove obsolete wording, the only exception a readnone function can
>>> throw
>>> is the empty set. :) Thanks to Fritz for pointing this out.
>>>
>> what's wrong with a readonly function using unwind? I think
>> the use of unwind is orthogonal to readonly: it's what the
>> nounwind attribute is for. Of course a readonly function can't
>> call the C++ throw routine etc, but that's a different issue.
>> If you want readonly to mean: doesn't do anything annoying
>> (no side-effects), then the name should be changed, and the
>> function attributes taught to do loop analysis and not mark
>> a function readonly unless all loops are finite etc. I think
>> it is better to keep readonly and nounwind separate.
>>
>
> I can definitely be convinced :), but my understanding is that the
> compiler currently deletes readonly/readnone calls if they are dead.
> We could change this to also require them to be nounwind, and change
> the C front-ends to have pure/const also add nounwind.
I think gcc's pure/const attributes imply nounwind, though the
documentation doesn't explicitly say so:
`const'
Many functions do not examine any values except their arguments,
and have no effects except the return value. Basically this is
just slightly more strict class than the `pure' attribute below,
since function is not allowed to read global memory.
I read "No effect except the return value" = cannot throw exceptions,
does not write to global memory, ...
If this is correct, then nounwind should be added by the C frontend.
Also a function marked as pure/const is not allowed to have infinite
loops either:
"Interesting non-pure functions are functions with infinite loops
or those depending on volatile memory or other system resource,
that may change between two consecutive calls (such as `feof' in a
multithreading environment)"
Of course LLVM can define readonly/readnone to have less strict
requirements, but then the C frontend should add more attributes than
just 'readonly/readnone' for
functions marked pure/const to match gcc's definition if we want
optimizers to take advantage of knowing the strict requirements.
Also what happens with C++'s const member functions?
If there are mutable class members they aren't technically readonly,
since they have the side-effect of modifying the object.
However most people use this as a 'logical' const, i.e. the object may
be modified, but the new object is equivalent to the old one.
Can this be modeled via an LLVM attribute?
Best regards,
--Edwin
From baldrick at free.fr Mon May 4 04:06:09 2009
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 4 May 2009 11:06:09 +0200
Subject: [llvm-commits] [llvm] r70790 - /llvm/trunk/docs/LangRef.html
In-Reply-To: <49FEAC01.4030708@gmail.com>
References: <200905031906.n43J60Bg012814@zion.cs.uiuc.edu>
<470D68BA-BCC1-4F82-9D78-426358B58E2E@nondot.org>
<49FEAC01.4030708@gmail.com>
Message-ID: <200905041106.10398.baldrick@free.fr>
Hi Edwin,
> I think gcc's pure/const attributes imply nounwind, though the
> documentation doesn't explicitly say so:
>
> `const'
> Many functions do not examine any values except their arguments,
> and have no effects except the return value. Basically this is
> just slightly more strict class than the `pure' attribute below,
> since function is not allowed to read global memory.
>
>
> I read "No effect except the return value" = cannot throw exceptions,
> does not write to global memory, ...
this comes up with great regularity on the gcc mailing list. One reason
is that Ada wants 'const' functions to be able to throw exceptions (so
that Ada's pure can be mapped onto 'const'), while C people tend to feel
that 'const' should mean "no side effects", so don't think such functions
should throw exceptions. I don't think any decision was made. I think the
solution is to break 'const' up into multiple concepts, i.e. do as you
suggest: have C map 'const' to readnone+nounwind, and have Ada map 'pure'
to readnone.
> If this is correct, then nounwind should be added by the C frontend.
I agree.
> Also a function marked as pure/const is not allowed to have infinite
> loops either:
>
> "Interesting non-pure functions are functions with infinite loops
> or those depending on volatile memory or other system resource,
> that may change between two consecutive calls (such as `feof' in a
> multithreading environment)"
See PR965. The suggested solution is to have yet another
attribute ("willreturn", "finite" or something like that)
that can be used to mark functions that will not infinite loop.
Then have the C front-end add that to 'const' functions, and
have a pass that deduces it using loop info.
> Of course LLVM can define readonly/readnone to have less strict
> requirements, but then the C frontend should add more attributes than
> just 'readonly/readnone' for
> functions marked pure/const to match gcc's definition if we want
> optimizers to take advantage of knowing the strict requirements.
Right.
> Also what happens with C++'s const member functions?
Nothing special is done for them right now.
> If there are mutable class members they aren't technically readonly,
> since they have the side-effect of modifying the object.
Yup.
> However most people use this as a 'logical' const, i.e. the object may
> be modified, but the new object is equivalent to the old one.
> Can this be modeled via an LLVM attribute?
You could always cheat and mark it readonly/readnone anyway. This
might work in some circumstances if no-one can tell that these modifications
are going on.
Ciao,
Duncan.
From eli.friedman at gmail.com Mon May 4 04:22:04 2009
From: eli.friedman at gmail.com (Eli Friedman)
Date: Mon, 4 May 2009 02:22:04 -0700
Subject: [llvm-commits] [llvm] r70790 - /llvm/trunk/docs/LangRef.html
In-Reply-To: <200905041106.10398.baldrick@free.fr>
References: <200905031906.n43J60Bg012814@zion.cs.uiuc.edu>
<470D68BA-BCC1-4F82-9D78-426358B58E2E@nondot.org>
<49FEAC01.4030708@gmail.com> <200905041106.10398.baldrick@free.fr>
Message-ID:
2009/5/4 Duncan Sands :
>> However most people use this as a 'logical' const, i.e. the object may
>> be modified, but the new object is equivalent to the old one.
>> Can this be modeled via an LLVM attribute?
>
> You could always cheat and mark it readonly/readnone anyway. ?This
> might work in some circumstances if no-one can tell that these modifications
> are going on.
That would get to be extremely nasty... for example, take an class
which caches the results of queries in a hashtable. Suppose only some
of the hashtable queries get inlined: then the compiler could end up
reusing the saved hashtable even though it moved because the hashtable
grew.
-Eli
From nicolas.geoffray at lip6.fr Mon May 4 04:54:36 2009
From: nicolas.geoffray at lip6.fr (Nicolas Geoffray)
Date: Mon, 04 May 2009 11:54:36 +0200
Subject: [llvm-commits] [llvm] r70820 - in /llvm/trunk:
lib/Transforms/Scalar/JumpThreading.cpp
test/Transforms/JumpThreading/no-irreducible-loops.ll
In-Reply-To: <200905040228.n442S8tg027269@zion.cs.uiuc.edu>
References: <200905040228.n442S8tg027269@zion.cs.uiuc.edu>
Message-ID: <49FEBB5C.4090707@lip6.fr>
Hi Chris,
Chris Lattner wrote:
> +#ifdef NDEBUG
> + SmallPtrSet LoopHeaders;
> +#else
> + SmallSet, 16> LoopHeaders;
> +#endif
>
>
> @@ -109,15 +121,42 @@
> DOUT << " JT: Deleting dead block '" << BB->getNameStart()
> << "' with terminator: " << *BB->getTerminator();
> DeleteDeadBlock(BB);
> + LoopHeaders.erase(BB);
>
SmallSet is an AssertingVH, so erasing the block in the LoopHeaders
should come before deleting the block.
Nicolas
From nicolas.geoffray at lip6.fr Mon May 4 05:20:30 2009
From: nicolas.geoffray at lip6.fr (Nicolas Geoffray)
Date: Mon, 04 May 2009 12:20:30 +0200
Subject: [llvm-commits] [llvm] r70820 - in /llvm/trunk:
lib/Transforms/Scalar/JumpThreading.cpp
test/Transforms/JumpThreading/no-irreducible-loops.ll
In-Reply-To: <49FEBB5C.4090707@lip6.fr>
References: <200905040228.n442S8tg027269@zion.cs.uiuc.edu>
<49FEBB5C.4090707@lip6.fr>
Message-ID: <49FEC16E.3000005@lip6.fr>
Nicolas Geoffray wrote:
>
> SmallSet is an AssertingVH, so erasing the block in the LoopHeaders
> should come before deleting the block.
>
>
Woops, read LoopHeaders instead of SmallSet.
> Nicolas
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
From asl at math.spbu.ru Mon May 4 05:24:53 2009
From: asl at math.spbu.ru (Anton Korobeynikov)
Date: Mon, 04 May 2009 10:24:53 -0000
Subject: [llvm-commits] [llvm] r70848 - /llvm/trunk/docs/GettingStarted.html
Message-ID: <200905041024.n44AOv79021738@zion.cs.uiuc.edu>
Author: asl
Date: Mon May 4 05:24:46 2009
New Revision: 70848
URL: http://llvm.org/viewvc/llvm-project?rev=70848&view=rev
Log:
It turns out that this version of gcc is broken (cygwin is well-known in shipping
of broken/buggy/snapshot-based compilers)
Modified:
llvm/trunk/docs/GettingStarted.html
Modified: llvm/trunk/docs/GettingStarted.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GettingStarted.html?rev=70848&r1=70847&r2=70848&view=diff
==============================================================================
--- llvm/trunk/docs/GettingStarted.html (original)
+++ llvm/trunk/docs/GettingStarted.html Mon May 4 05:24:46 2009
@@ -545,6 +545,9 @@
about symbols remaining in the table on destruction.
GCC 4.1.2 20071124 (Red Hat 4.1.2-42): Suffers from the same symptoms
as the previous one. It appears to work with ENABLE_OPTIMIZED=0 (the default).
+Cygwin GCC 4.3.2 20080827 (beta) 2:
+ Users reported various problems related
+ with link errors when using this GCC version.
GNU ld 2.16.X. Some 2.16.X versions of the ld linker will produce very
long warning messages complaining that some ".gnu.linkonce.t.*" symbol was
From asl at math.spbu.ru Mon May 4 05:25:31 2009
From: asl at math.spbu.ru (Anton Korobeynikov)
Date: Mon, 04 May 2009 10:25:31 -0000
Subject: [llvm-commits] [llvm] r70849 - /llvm/trunk/Makefile.rules
Message-ID: <200905041025.n44APWof021763@zion.cs.uiuc.edu>
Author: asl
Date: Mon May 4 05:25:30 2009
New Revision: 70849
URL: http://llvm.org/viewvc/llvm-project?rev=70849&view=rev
Log:
Workaround libstdc++ bug when crosscompiling to mingw.
Patch by Jay Foad!
Modified:
llvm/trunk/Makefile.rules
Modified: llvm/trunk/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=70849&r1=70848&r2=70849&view=diff
==============================================================================
--- llvm/trunk/Makefile.rules (original)
+++ llvm/trunk/Makefile.rules Mon May 4 05:25:30 2009
@@ -361,6 +361,15 @@
LD.Flags += -Wl,--no-relax
endif
+ifeq ($(OS),MingW)
+ ifeq ($(LLVM_CROSS_COMPILING),1)
+ # Work around http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525016
+ ifdef TOOLNAME
+ LD.Flags += -Wl,--allow-multiple-definition
+ endif
+ endif
+endif
+
#--------------------------------------------------------------------
# Directory locations
#--------------------------------------------------------------------
From baldrick at free.fr Mon May 4 07:48:16 2009
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 04 May 2009 12:48:16 -0000
Subject: [llvm-commits] [llvm-gcc-4.2] r70855 - in /llvm-gcc-4.2/trunk/gcc:
config/i386/llvm-i386-target.h llvm-types.cpp
Message-ID: <200905041248.n44CmH3Q026592@zion.cs.uiuc.edu>
Author: baldrick
Date: Mon May 4 07:48:14 2009
New Revision: 70855
URL: http://llvm.org/viewvc/llvm-project?rev=70855&view=rev
Log:
Fix PR3967: allow enums and references to have
the "inreg" attribute, not just integers and
pointers. Based on a patch by Haohui Mai.
Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=70855&r1=70854&r2=70855&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Mon May 4 07:48:14 2009
@@ -76,8 +76,8 @@
PAttribute |= Attribute::InReg; \
else \
local_fp_regparm = 0; \
- } else if (TREE_CODE(Type) == INTEGER_TYPE || \
- TREE_CODE(Type) == POINTER_TYPE) { \
+ } else if (INTEGRAL_TYPE_P(Type) || \
+ POINTER_TYPE_P(Type)) { \
int words = \
(Size + BITS_PER_WORD - 1) / BITS_PER_WORD; \
local_regparm -= words; \
Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=70855&r1=70854&r2=70855&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon May 4 07:48:14 2009
@@ -1241,8 +1241,8 @@
#ifdef LLVM_TARGET_ENABLE_REGPARM
// Allow the target to mark this as inreg.
- if (TREE_CODE(ArgTy) == INTEGER_TYPE || TREE_CODE(ArgTy) == POINTER_TYPE ||
- TREE_CODE(ArgTy) == REAL_TYPE)
+ if (INTEGRAL_TYPE_P(ArgTy) || POINTER_TYPE_P(ArgTy) ||
+ SCALAR_FLOAT_TYPE_P(ArgTy))
LLVM_ADJUST_REGPARM_ATTRIBUTE(PAttributes, ArgTy,
TREE_INT_CST_LOW(TYPE_SIZE(ArgTy)),
local_regparam, local_fp_regparam);
From baldrick at free.fr Mon May 4 07:54:15 2009
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 04 May 2009 12:54:15 -0000
Subject: [llvm-commits] [llvm] r70856 -
/llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c
Message-ID: <200905041254.n44CsJC4026791@zion.cs.uiuc.edu>
Author: baldrick
Date: Mon May 4 07:54:02 2009
New Revision: 70856
URL: http://llvm.org/viewvc/llvm-project?rev=70856&view=rev
Log:
Testcase for PR3967.
Added:
llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c
Added: llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c?rev=70856&view=auto
==============================================================================
--- llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c (added)
+++ llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c Mon May 4 07:54:02 2009
@@ -0,0 +1,17 @@
+// RUN: llvm-gcc -S -m32 -mregparm=3 %s -emit-llvm -o - | grep {inreg %action}
+// XTARGET: x86
+// PR3967
+
+enum kobject_action {
+ KOBJ_ADD,
+ KOBJ_REMOVE,
+ KOBJ_CHANGE,
+ KOBJ_MOVE,
+ KOBJ_ONLINE,
+ KOBJ_OFFLINE,
+ KOBJ_MAX
+};
+
+struct kobject;
+
+int kobject_uevent(struct kobject *kobj, enum kobject_action action) {}
From akyrtzi at gmail.com Mon May 4 11:23:49 2009
From: akyrtzi at gmail.com (Argiris Kirtzidis)
Date: Mon, 04 May 2009 16:23:49 -0000
Subject: [llvm-commits] [llvm] r70871 - in /llvm/trunk:
lib/CodeGen/AsmPrinter/DwarfWriter.cpp
lib/CodeGen/SelectionDAG/FastISel.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
test/DebugInfo/2009-01-29-HeaderLocation.ll
utils/TableGen/AsmWriterEmitter.cpp
Message-ID: <200905041623.n44GNnOc001289@zion.cs.uiuc.edu>
Author: akirtzidis
Date: Mon May 4 11:23:49 2009
New Revision: 70871
URL: http://llvm.org/viewvc/llvm-project?rev=70871&view=rev
Log:
-Remove the DwarfWriter::RecordSourceLine calls from the instruction selectors.
-Depend on DebugLocs for source line info.
(Comes with Regression-Be-Gone(tm))
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
llvm/trunk/test/DebugInfo/2009-01-29-HeaderLocation.ll
llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=70871&r1=70870&r2=70871&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Mon May 4 11:23:49 2009
@@ -3262,11 +3262,12 @@
// Assumes in correct section after the entry point.
EmitLabel("func_begin", ++SubprogramCount);
- // Emit label for the implicitly defined dbg.stoppoint at the start of
- // the function.
- if (!Lines.empty()) {
- const SrcLineInfo &LineInfo = Lines[0];
- Asm->printLabel(LineInfo.getLabelID());
+ DebugLoc FDL = MF->getDefaultDebugLoc();
+ if (!FDL.isUnknown()) {
+ DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
+ unsigned LabelID = RecordSourceLine(DLT.Line, DLT.Col,
+ DICompileUnit(DLT.CompileUnit));
+ Asm->printLabel(LabelID);
}
if (TimePassesIsEnabled)
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=70871&r1=70870&r2=70871&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Mon May 4 11:23:49 2009
@@ -333,11 +333,6 @@
unsigned Col = SPI->getColumn();
unsigned Idx = MF.getOrCreateDebugLocID(CU.getGV(), Line, Col);
setCurDebugLoc(DebugLoc::get(Idx));
- if (DW && DW->ShouldEmitDwarfDebug()) {
- unsigned ID = DW->RecordSourceLine(Line, Col, CU);
- const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
- BuildMI(MBB, DL, II).addImm(ID);
- }
}
return true;
}
@@ -402,7 +397,7 @@
CompileUnit.getGV(), Line, 0)));
if (DW && DW->ShouldEmitDwarfDebug()) {
- unsigned LabelID = DW->RecordSourceLine(Line, 0, CompileUnit);
+ unsigned LabelID = MMI->NextLabelID();
const TargetInstrDesc &II = TII.get(TargetInstrInfo::DBG_LABEL);
BuildMI(MBB, DL, II).addImm(LabelID);
DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc);
@@ -414,10 +409,9 @@
} else {
// Record the source line.
unsigned Line = Subprogram.getLineNumber();
- setCurDebugLoc(DebugLoc::get(MF.getOrCreateDebugLocID(
+ MF.setDefaultDebugLoc(DebugLoc::get(MF.getOrCreateDebugLocID(
CompileUnit.getGV(), Line, 0)));
if (DW && DW->ShouldEmitDwarfDebug()) {
- DW->RecordSourceLine(Line, 0, CompileUnit);
// llvm.dbg.func_start also defines beginning of function scope.
DW->RecordRegionStart(cast(FSI->getSubprogram()));
}
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=70871&r1=70870&r2=70871&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon May 4 11:23:49 2009
@@ -3980,7 +3980,7 @@
MF.getOrCreateDebugLocID(CompileUnit.getGV(), Line, 0)));
if (DW && DW->ShouldEmitDwarfDebug()) {
- unsigned LabelID = DW->RecordSourceLine(Line, 0, CompileUnit);
+ unsigned LabelID = DAG.getMachineModuleInfo()->NextLabelID();
DAG.setRoot(DAG.getLabel(ISD::DBG_LABEL, getCurDebugLoc(),
getRoot(), LabelID));
DebugLocTuple PrevLocTpl = MF.getDebugLocTuple(PrevLoc);
@@ -3992,10 +3992,9 @@
} else {
// Record the source line.
unsigned Line = Subprogram.getLineNumber();
- setCurDebugLoc(DebugLoc::get(
+ MF.setDefaultDebugLoc(DebugLoc::get(
MF.getOrCreateDebugLocID(CompileUnit.getGV(), Line, 0)));
if (DW && DW->ShouldEmitDwarfDebug()) {
- DW->RecordSourceLine(Line, 0, CompileUnit);
// llvm.dbg.func_start also defines beginning of function scope.
DW->RecordRegionStart(cast(FSI.getSubprogram()));
}
Modified: llvm/trunk/test/DebugInfo/2009-01-29-HeaderLocation.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-01-29-HeaderLocation.ll?rev=70871&r1=70870&r2=70871&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/2009-01-29-HeaderLocation.ll (original)
+++ llvm/trunk/test/DebugInfo/2009-01-29-HeaderLocation.ll Mon May 4 11:23:49 2009
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | llc | grep "m.h" | count 1
+; RUN: llvm-as < %s | llc | grep "\\"m.h\\"" | count 1
target triple = "i386-apple-darwin9.6"
%llvm.dbg.anchor.type = type { i32, i32 }
%llvm.dbg.basictype.type = type { i32, { }*, i8*, { }*, i32, i64, i64, i64, i32, i32 }
Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=70871&r1=70870&r2=70871&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Mon May 4 11:23:49 2009
@@ -650,12 +650,12 @@
O << "\";\n\n";
O << " if (TAI->doesSupportDebugInformation() &&\n"
- << " DW->ShouldEmitDwarfDebug() && OptLevel != CodeGenOpt::None) {\n"
+ << " DW->ShouldEmitDwarfDebug()) {\n"
<< " DebugLoc CurDL = MI->getDebugLoc();\n\n"
<< " if (!CurDL.isUnknown()) {\n"
<< " static DebugLocTuple PrevDLT(0, ~0U, ~0U);\n"
<< " DebugLocTuple CurDLT = MF->getDebugLocTuple(CurDL);\n\n"
- << " if (PrevDLT.CompileUnit != 0 && PrevDLT != CurDLT)\n"
+ << " if (CurDLT.CompileUnit != 0 && PrevDLT != CurDLT)\n"
<< " printLabel(DW->RecordSourceLine(CurDLT.Line, CurDLT.Col,\n"
<< " DICompileUnit(CurDLT.CompileUnit)));\n\n"
<< " PrevDLT = CurDLT;\n"
From sabre at nondot.org Mon May 4 11:29:24 2009
From: sabre at nondot.org (Chris Lattner)
Date: Mon, 04 May 2009 16:29:24 -0000
Subject: [llvm-commits] [llvm] r70872 -
/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
Message-ID: <200905041629.n44GTOVI001473@zion.cs.uiuc.edu>
Author: lattner
Date: Mon May 4 11:29:24 2009
New Revision: 70872
URL: http://llvm.org/viewvc/llvm-project?rev=70872&view=rev
Log:
fix some problems spotted by Duncan and Nicolas Geoffray
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=70872&r1=70871&r2=70872&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon May 4 11:29:24 2009
@@ -120,8 +120,8 @@
BB != &BB->getParent()->getEntryBlock()) {
DOUT << " JT: Deleting dead block '" << BB->getNameStart()
<< "' with terminator: " << *BB->getTerminator();
- DeleteDeadBlock(BB);
LoopHeaders.erase(BB);
+ DeleteDeadBlock(BB);
Changed = true;
}
}
@@ -133,7 +133,7 @@
return EverChanged;
}
-/// FindLoopHeaders - We do not wan jump threading to turn proper loop
+/// FindLoopHeaders - We do not want jump threading to turn proper loop
/// structures into irreducible loops. Doing this breaks up the loop nesting
/// hierarchy and pessimizes later transformations. To prevent this from
/// happening, we first have to find the loop headers. Here we approximate this
From clattner at apple.com Mon May 4 11:37:16 2009
From: clattner at apple.com (Chris Lattner)
Date: Mon, 4 May 2009 09:37:16 -0700
Subject: [llvm-commits] [llvm] r70790 - /llvm/trunk/docs/LangRef.html
In-Reply-To: <200905040942.54978.baldrick@free.fr>
References: <200905031906.n43J60Bg012814@zion.cs.uiuc.edu>
<200905032206.29498.baldrick@free.fr>
<470D68BA-BCC1-4F82-9D78-426358B58E2E@nondot.org>
<200905040942.54978.baldrick@free.fr>
Message-ID: <2C582DE5-9DA5-43D6-B46E-76740F5C98F2@apple.com>
On May 4, 2009, at 12:42 AM, Duncan Sands wrote:
>> I can definitely be convinced :), but my understanding is that the
>> compiler currently deletes readonly/readnone calls if they are dead.
>
> yes, this is a known bug :)
Ok, well I still think it is good to have the docs and code line
up. :) That said, I do agree fully now that decoupling readnone/only
and nothrow is the right thing to do.
If you want to make this change, please make sure that all of the
compiler agrees, update llvm-gcc, and fix the docs to be very clear
about this. It is probably worth mentioning explicitly that while non-
nothrow readonly functions are allowed to unwind, they cannot use C++
EH to do it because it changes global state.
>> We could change this to also require them to be nounwind, and change
>> the C front-ends to have pure/const also add nounwind. What do you
>> think?
>
> That's my preferred solution.
Ok, I agree that it makes sense. It would also be good to change llvm-
gcc to set nounwind on all pure/const functions.
Duncan wrote:
> I had a look at isInstructionTriviallyDead
> and was struck by the fact that it doesn't check isTrapping. Is it
> valid
> to delete a divide by zero if the result has no uses? Currently
> this is
> done. If so, is it valid to delete a readonly call even if it may
> throw
> an exception?
Eli responded:
> Yes, it is valid; division by zero is undefined behavior, so it can do
> anything; we make no attempt to preserve any traps from that.
These are the C semantics, and the semantics that LLVM IR currently
has. However, in the future, we will probably end up extending LLVM
IR to better serve other languages. In a language that requires a
trap to be generated for things like this (and/or null pointer
dereferences etc), then an exception could be generated. The
optimizer will have to be careful not to do unsafe transformations.
For example, a function that loads a potentially null pointer and is
supposed to trap on it cannot be deleted if dead, but it can be CSE'd.
-Chris
From clattner at apple.com Mon May 4 11:38:49 2009
From: clattner at apple.com (Chris Lattner)
Date: Mon, 4 May 2009 09:38:49 -0700
Subject: [llvm-commits] [llvm] r70790 - /llvm/trunk/docs/LangRef.html
In-Reply-To: <49FEAC01.4030708@gmail.com>
References: <200905031906.n43J60Bg012814@zion.cs.uiuc.edu>
<200905032206.29498.baldrick@free.fr>
<470D68BA-BCC1-4F82-9D78-426358B58E2E@nondot.org>
<49FEAC01.4030708@gmail.com>
Message-ID:
On May 4, 2009, at 1:49 AM, T?r?k Edwin wrote:
> Also what happens with C++'s const member functions?
> If there are mutable class members they aren't technically readonly,
> since they have the side-effect of modifying the object.
> However most people use this as a 'logical' const, i.e. the object may
> be modified, but the new object is equivalent to the old one.
> Can this be modeled via an LLVM attribute?
No, this cannot be modeled, because const is allowed to be cast away.
-Chris
From baldrick at free.fr Mon May 4 11:45:55 2009
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 04 May 2009 16:45:55 -0000
Subject: [llvm-commits] [llvm-gcc-4.2] r70874 -
/llvm-gcc-4.2/trunk/gcc/c-common.c
Message-ID: <200905041645.n44GjtJ0002012@zion.cs.uiuc.edu>
Author: baldrick
Date: Mon May 4 11:45:55 2009
New Revision: 70874
URL: http://llvm.org/viewvc/llvm-project?rev=70874&view=rev
Log:
In C-like languages, marking a function pure/const
means it cannot throw an exception. This is not
the case in other languages such as Ada. Make this
explicit by having pure/const imply nothrow for C
and friends.
Modified:
llvm-gcc-4.2/trunk/gcc/c-common.c
Modified: llvm-gcc-4.2/trunk/gcc/c-common.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-common.c?rev=70874&r1=70873&r2=70874&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-common.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-common.c Mon May 4 11:45:55 2009
@@ -4739,9 +4739,12 @@
tree type = TREE_TYPE (*node);
/* See FIXME comment on noreturn in c_common_attribute_table. */
- if (TREE_CODE (*node) == FUNCTION_DECL)
+ /* LLVM LOCAL begin */
+ if (TREE_CODE (*node) == FUNCTION_DECL) {
TREE_READONLY (*node) = 1;
- else if (TREE_CODE (type) == POINTER_TYPE
+ TREE_NOTHROW (*node) = 1;
+ } else if (TREE_CODE (type) == POINTER_TYPE
+ /* LLVM LOCAL end */
&& TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
TREE_TYPE (*node)
= build_pointer_type
@@ -5573,10 +5576,13 @@
handle_pure_attribute (tree *node, tree name, tree ARG_UNUSED (args),
int ARG_UNUSED (flags), bool *no_add_attrs)
{
- if (TREE_CODE (*node) == FUNCTION_DECL)
+ /* LLVM LOCAL begin */
+ if (TREE_CODE (*node) == FUNCTION_DECL) {
DECL_IS_PURE (*node) = 1;
- /* ??? TODO: Support types. */
- else
+ TREE_NOTHROW (*node) = 1;
+ } else
+ /* LLVM LOCAL end */
+ /* ??? TODO: Support types. */
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
From baldrick at free.fr Mon May 4 11:47:11 2009
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 04 May 2009 16:47:11 -0000
Subject: [llvm-commits] [llvm] r70875 -
/llvm/trunk/test/FrontendC++/2009-05-04-PureConstNounwind.cpp
Message-ID: <200905041647.n44GlBbP002059@zion.cs.uiuc.edu>
Author: baldrick
Date: Mon May 4 11:47:11 2009
New Revision: 70875
URL: http://llvm.org/viewvc/llvm-project?rev=70875&view=rev
Log:
Check that pure/const functions are marked nounwind.
Added:
llvm/trunk/test/FrontendC++/2009-05-04-PureConstNounwind.cpp
Added: llvm/trunk/test/FrontendC++/2009-05-04-PureConstNounwind.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2009-05-04-PureConstNounwind.cpp?rev=70875&view=auto
==============================================================================
--- llvm/trunk/test/FrontendC++/2009-05-04-PureConstNounwind.cpp (added)
+++ llvm/trunk/test/FrontendC++/2009-05-04-PureConstNounwind.cpp Mon May 4 11:47:11 2009
@@ -0,0 +1,8 @@
+// RUN: %llvmgxx -S -emit-llvm %s -o - | grep nounwind | count 4
+int c(void) __attribute__((const));
+int p(void) __attribute__((pure));
+int t(void);
+
+int f(void) {
+ return c() + p() + t();
+}
From baldrick at free.fr Mon May 4 11:50:30 2009
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 04 May 2009 16:50:30 -0000
Subject: [llvm-commits] [llvm] r70876 - in /llvm/trunk:
lib/Analysis/CaptureTracking.cpp
test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll
Message-ID: <200905041650.n44GoXRA002178@zion.cs.uiuc.edu>
Author: baldrick
Date: Mon May 4 11:50:29 2009
New Revision: 70876
URL: http://llvm.org/viewvc/llvm-project?rev=70876&view=rev
Log:
Teach capture tracking that readonly functions can
only capture their arguments by returning them or
throwing an exception or not based on the argument
value. Patch essentially by Frits van Bommel.
Modified:
llvm/trunk/lib/Analysis/CaptureTracking.cpp
llvm/trunk/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll
Modified: llvm/trunk/lib/Analysis/CaptureTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CaptureTracking.cpp?rev=70876&r1=70875&r2=70876&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CaptureTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/CaptureTracking.cpp Mon May 4 11:50:29 2009
@@ -49,11 +49,7 @@
switch (I->getOpcode()) {
case Instruction::Call:
case Instruction::Invoke: {
- CallSite CS = CallSite::get(I);
- // Not captured if the callee is readonly and doesn't return a copy
- // through its return value.
- if (CS.onlyReadsMemory() && I->getType() == Type::VoidTy)
- break;
+ CallSite CS(I);
// Not captured if only passed via 'nocapture' arguments. Note that
// calling a function pointer does not in itself cause the pointer to
@@ -62,46 +58,69 @@
// that loading a value from a pointer does not cause the pointer to be
// captured, even though the loaded value might be the pointer itself
// (think of self-referential objects).
+ bool MayBeCaptured = false;
CallSite::arg_iterator B = CS.arg_begin(), E = CS.arg_end();
for (CallSite::arg_iterator A = B; A != E; ++A)
- if (A->get() == V && !CS.paramHasAttr(A - B + 1, Attribute::NoCapture))
- // The parameter is not marked 'nocapture' - captured.
- return true;
- // Only passed via 'nocapture' arguments, or is the called function - not
- // captured.
+ if (A->get() == V && !CS.paramHasAttr(A-B+1, Attribute::NoCapture)) {
+ // The parameter is not marked 'nocapture' - handled by generic code
+ // below.
+ MayBeCaptured = true;
+ break;
+ }
+ if (!MayBeCaptured)
+ // Only passed via 'nocapture' arguments, or is the called function -
+ // not captured.
+ continue;
+ if (!CS.doesNotThrow())
+ // Even a readonly function can leak bits by throwing an exception or
+ // not depending on the input value.
+ return true;
+ // Fall through to the generic code.
break;
}
case Instruction::Free:
// Freeing a pointer does not cause it to be captured.
- break;
+ continue;
case Instruction::Load:
// Loading from a pointer does not cause it to be captured.
- break;
+ continue;
case Instruction::Ret:
if (ReturnCaptures)
return true;
- break;
+ continue;
case Instruction::Store:
if (V == I->getOperand(0))
// Stored the pointer - it may be captured.
return true;
// Storing to the pointee does not cause the pointer to be captured.
- break;
- case Instruction::BitCast:
- case Instruction::GetElementPtr:
- case Instruction::PHI:
- case Instruction::Select:
- // The original value is not captured via this if the new value isn't.
- for (Instruction::use_iterator UI = I->use_begin(), UE = I->use_end();
- UI != UE; ++UI) {
- Use *U = &UI.getUse();
- if (Visited.insert(U))
- Worklist.push_back(U);
- }
- break;
- default:
- // Something else - be conservative and say it is captured.
+ continue;
+ }
+
+ // If it may write to memory and isn't one of the special cases above,
+ // be conservative and assume the pointer is captured.
+ if (I->mayWriteToMemory())
return true;
+
+ // If the instruction doesn't write memory, it can only capture by
+ // having its own value depend on the input value.
+ const Type* Ty = I->getType();
+ if (Ty == Type::VoidTy)
+ // The value of an instruction can't be a copy if it can't contain any
+ // information.
+ continue;
+ if (!isa(Ty))
+ // At the moment, we don't track non-pointer values, so be conservative
+ // and assume the pointer is captured.
+ // FIXME: Track these too. This would need to be done very carefully as
+ // it is easy to leak bits via control flow if integer values are allowed.
+ return true;
+
+ // The original value is not captured via this if the new value isn't.
+ for (Instruction::use_iterator UI = I->use_begin(), UE = I->use_end();
+ UI != UE; ++UI) {
+ Use *U = &UI.getUse();
+ if (Visited.insert(U))
+ Worklist.push_back(U);
}
}
Modified: llvm/trunk/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll?rev=70876&r1=70875&r2=70876&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll (original)
+++ llvm/trunk/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll Mon May 4 11:50:29 2009
@@ -39,6 +39,16 @@
ret i1 %val
}
+declare void @throw_if_bit_set(i8*, i8) readonly
+define i1 @c6(i8* %q, i8 %bit) {
+ invoke void @throw_if_bit_set(i8* %q, i8 %bit)
+ to label %ret0 unwind label %ret1
+ret0:
+ ret i1 0
+ret1:
+ ret i1 1
+}
+
define i32 @nc1(i32* %q, i32* %p, i1 %b) {
e:
br label %l
@@ -63,14 +73,20 @@
ret void
}
-declare void @external(i8*) readonly
+declare void @external(i8*) readonly nounwind
define void @nc4(i8* %p) {
call void @external(i8* %p)
ret void
}
-define void @nc5(void (i8*)* %f, i8* %p) {
- call void %f(i8* %p) readonly
- call void %f(i8* nocapture %p)
+define void @nc5(void (i8*)* %p, i8* %r) {
+ call void %p(i8* %r)
+ call void %p(i8* nocapture %r)
+ ret void
+}
+
+declare i8* @external_identity(i8*) readonly nounwind
+define void @nc6(i8* %p) {
+ call i8* @external_identity(i8* %p)
ret void
}
From gohman at apple.com Mon May 4 12:09:52 2009
From: gohman at apple.com (Dan Gohman)
Date: Mon, 04 May 2009 17:09:52 -0000
Subject: [llvm-commits] [llvm] r70879 -
/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
Message-ID: <200905041709.n44H9qM5002807@zion.cs.uiuc.edu>
Author: djg
Date: Mon May 4 12:09:51 2009
New Revision: 70879
URL: http://llvm.org/viewvc/llvm-project?rev=70879&view=rev
Log:
Quotes are used for including llvm headers, rather than angles.
Modified:
llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
Modified: llvm/trunk/utils/TableGen/DAGISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelEmitter.cpp?rev=70879&r1=70878&r2=70879&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelEmitter.cpp Mon May 4 12:09:51 2009
@@ -2102,7 +2102,7 @@
OS << "// Include standard, target-independent definitions and methods used\n"
<< "// by the instruction selector.\n";
- OS << "#include \n\n";
+ OS << "#include \"llvm/CodeGen/DAGISelHeader.h\"\n\n";
EmitNodeTransforms(OS);
EmitPredicateFunctions(OS);
From gohman at apple.com Mon May 4 12:11:06 2009
From: gohman at apple.com (Dan Gohman)
Date: Mon, 04 May 2009 17:11:06 -0000
Subject: [llvm-commits] [llvm] r70880 -
/llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp
Message-ID: <200905041711.n44HB632002871@zion.cs.uiuc.edu>
Author: djg
Date: Mon May 4 12:11:06 2009
New Revision: 70880
URL: http://llvm.org/viewvc/llvm-project?rev=70880&view=rev
Log:
Trim unnecessary #includes.
Modified:
llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp
Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp?rev=70880&r1=70879&r2=70880&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp Mon May 4 12:11:06 2009
@@ -28,8 +28,6 @@
#include "llvm/Target/TargetLowering.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
-#include
-#include
using namespace llvm;
/// MSP430DAGToDAGISel - MSP430 specific code to select MSP430 machine
From gohman at apple.com Mon May 4 12:12:00 2009
From: gohman at apple.com (Dan Gohman)
Date: Mon, 04 May 2009 17:12:00 -0000
Subject: [llvm-commits] [llvm] r70881 - /llvm/trunk/lib/Target/MSP430/
Message-ID: <200905041712.n44HC08A002912@zion.cs.uiuc.edu>
Author: djg
Date: Mon May 4 12:12:00 2009
New Revision: 70881
URL: http://llvm.org/viewvc/llvm-project?rev=70881&view=rev
Log:
Add an svn:ignore property.
Modified:
llvm/trunk/lib/Target/MSP430/ (props changed)
Propchange: llvm/trunk/lib/Target/MSP430/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon May 4 12:12:00 2009
@@ -0,0 +1,4 @@
+Debug
+Release
+Release-Asserts
+*.inc
From gohman at apple.com Mon May 4 12:25:21 2009
From: gohman at apple.com (Dan Gohman)
Date: Mon, 04 May 2009 17:25:21 -0000
Subject: [llvm-commits] [llvm] r70882 - /llvm/trunk/lib/VMCore/Value.cpp
Message-ID: <200905041725.n44HPLoW003469@zion.cs.uiuc.edu>
Author: djg
Date: Mon May 4 12:25:21 2009
New Revision: 70882
URL: http://llvm.org/viewvc/llvm-project?rev=70882&view=rev
Log:
Use true instead of 1 for a boolean value. And fix a copy+pasto
in a comment.
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=70882&r1=70881&r2=70882&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Value.cpp (original)
+++ llvm/trunk/lib/VMCore/Value.cpp Mon May 4 12:25:21 2009
@@ -406,8 +406,8 @@
typedef DenseMap ValueHandlesTy;
static ManagedStatic ValueHandles;
-/// AddToUseList - Add this ValueHandle to the use list for VP, where List is
-/// known to point into the existing use list.
+/// AddToExistingUseList - Add this ValueHandle to the use list for VP, where
+/// List is known to point into the existing use list.
void ValueHandleBase::AddToExistingUseList(ValueHandleBase **List) {
assert(List && "Handle list is null?");
@@ -443,7 +443,7 @@
ValueHandleBase *&Entry = Handles[VP];
assert(Entry == 0 && "Value really did already have handles?");
AddToExistingUseList(&Entry);
- VP->HasValueHandle = 1;
+ VP->HasValueHandle = true;
// If reallocation didn't happen or if this was the first insertion, don't
// walk the table.
From eli.friedman at gmail.com Mon May 4 12:35:20 2009
From: eli.friedman at gmail.com (Eli Friedman)
Date: Mon, 4 May 2009 10:35:20 -0700
Subject: [llvm-commits] [llvm] r70790 - /llvm/trunk/docs/LangRef.html
In-Reply-To:
References: <200905031906.n43J60Bg012814@zion.cs.uiuc.edu>
<200905032206.29498.baldrick@free.fr>
<470D68BA-BCC1-4F82-9D78-426358B58E2E@nondot.org>
<49FEAC01.4030708@gmail.com>
Message-ID:
On Mon, May 4, 2009 at 9:38 AM, Chris Lattner wrote:
>
> On May 4, 2009, at 1:49 AM, T?r?k Edwin wrote:
>
>> Also what happens with C++'s const member functions?
>> If there are mutable class members they aren't technically readonly,
>> since they have the side-effect of modifying the object.
>> However most people use this as a 'logical' const, i.e. the object may
>> be modified, but the new object is equivalent to the old one.
>> Can this be modeled via an LLVM attribute?
>
> No, this cannot be modeled, because const is allowed to be cast away.
Well, not quite... per [dcl.type.cv], "Except that any class member
declared mutable (7.1.1) can be modified, any attempt to modify a
const object during its lifetime (3.8) results in undefined behavior."
That's a pretty narrow exception, though, and C++ programs generally
aren't written to take advantage of it.
-Eli
From isanbard at gmail.com Mon May 4 13:00:28 2009
From: isanbard at gmail.com (Bill Wendling)
Date: Mon, 04 May 2009 18:00:28 -0000
Subject: [llvm-commits] [llvm] r70886 -
/llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c
Message-ID: <200905041800.n44I0Se2005358@zion.cs.uiuc.edu>
Author: void
Date: Mon May 4 13:00:27 2009
New Revision: 70886
URL: http://llvm.org/viewvc/llvm-project?rev=70886&view=rev
Log:
Use %llvmgcc instead of llvm-gcc.
Modified:
llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c
Modified: llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c?rev=70886&r1=70885&r2=70886&view=diff
==============================================================================
--- llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c (original)
+++ llvm/trunk/test/FrontendC/2009-05-04-EnumInreg.c Mon May 4 13:00:27 2009
@@ -1,4 +1,4 @@
-// RUN: llvm-gcc -S -m32 -mregparm=3 %s -emit-llvm -o - | grep {inreg %action}
+// RUN: %llvmgcc -S -m32 -mregparm=3 %s -emit-llvm -o - | grep {inreg %action}
// XTARGET: x86
// PR3967
From isanbard at gmail.com Mon May 4 13:06:56 2009
From: isanbard at gmail.com (Bill Wendling)
Date: Mon, 4 May 2009 11:06:56 -0700
Subject: [llvm-commits] [llvm-gcc-4.2] r70801 -
/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
In-Reply-To: <200905040905.18847.baldrick@free.fr>
References: <200905032136.n43LaNFN018015@zion.cs.uiuc.edu>
<200905040905.18847.baldrick@free.fr>
Message-ID: <16e5fdf90905041106n6ed30aaeg89870c25de1ea088@mail.gmail.com>
On Mon, May 4, 2009 at 12:05 AM, Duncan Sands wrote:
> Hi Bill,
>
>> Don'e create debug info for ObjC metadata.
>
> how about setting DECL_ARTIFICIAL for such globals, and then teach
> the backend not to output debug info for globals with DECL_ARTIFICIAL
> set?
>
> /* Used to indicate that this DECL represents a compiler-generated entity. ?*/
> #define DECL_ARTIFICIAL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.artificial_flag)
>
Hi Duncan,
I'll run this past our ObjC expert here. He wrote most of the stuff.
Thanks!
-bw
From mrs at apple.com Mon May 4 13:34:35 2009
From: mrs at apple.com (Mike Stump)
Date: Mon, 04 May 2009 18:34:35 -0000
Subject: [llvm-commits] [llvm] r70891 - /llvm/trunk/
Message-ID: <200905041834.n44IYZ3s006759@zion.cs.uiuc.edu>
Author: mrs
Date: Mon May 4 13:34:35 2009
New Revision: 70891
URL: http://llvm.org/viewvc/llvm-project?rev=70891&view=rev
Log:
Update.
Removed:
llvm/trunk/
From isanbard at gmail.com Mon May 4 13:36:02 2009
From: isanbard at gmail.com (Bill Wendling)
Date: Mon, 4 May 2009 11:36:02 -0700
Subject: [llvm-commits] [llvm] r70891 - /llvm/trunk/
In-Reply-To: <200905041834.n44IYZ3s006759@zion.cs.uiuc.edu>
References: <200905041834.n44IYZ3s006759@zion.cs.uiuc.edu>
Message-ID: <16e5fdf90905041136v1c45bc57hbae99c9acb44e7ea@mail.gmail.com>
Huh?!
-bw
On Mon, May 4, 2009 at 11:34 AM, Mike Stump wrote:
> Author: mrs
> Date: Mon May ?4 13:34:35 2009
> New Revision: 70891
>
> URL: http://llvm.org/viewvc/llvm-project?rev=70891&view=rev
> Log:
> Update.
>
> Removed:
> ? ?llvm/trunk/
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
From anton at korobeynikov.info Mon May 4 13:34:15 2009
From: anton at korobeynikov.info (Anton Korobeynikov)
Date: Mon, 04 May 2009 22:34:15 +0400
Subject: [llvm-commits] [llvm] r70891 - /llvm/trunk/
In-Reply-To: <200905041834.n44IYZ3s006759@zion.cs.uiuc.edu>
References: <200905041834.n44IYZ3s006759@zion.cs.uiuc.edu>
Message-ID: <1241462055.18321.30.camel@aslstation>
Hello, Mike
> Author: mrs
> Date: Mon May 4 13:34:35 2009
> New Revision: 70891
>
> URL: http://llvm.org/viewvc/llvm-project?rev=70891&view=rev
> Log:
> Update.
>
> Removed:
> llvm/trunk/
Did you really want to delete trunk???
--
With best regards, Anton Korobeynikov.
Faculty of Mathematics & Mechanics, Saint Petersburg State University.
From isanbard at gmail.com Mon May 4 13:39:51 2009
From: isanbard at gmail.com (Bill Wendling)
Date: Mon, 4 May 2009 11:39:51 -0700
Subject: [llvm-commits] [llvm] r70891 - /llvm/trunk/
In-Reply-To: <1241462055.18321.30.camel@aslstation>
References: <200905041834.n44IYZ3s006759@zion.cs.uiuc.edu>
<1241462055.18321.30.camel@aslstation>
Message-ID: <16e5fdf90905041139v1bc8507ep355e550e1490e705@mail.gmail.com>
On Mon, May 4, 2009 at 11:34 AM, Anton Korobeynikov
wrote:
> Hello, Mike
>
>> Author: mrs
>> Date: Mon May ?4 13:34:35 2009
>> New Revision: 70891
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=70891&view=rev
>> Log:
>> Update.
>>
>> Removed:
>> ? ? llvm/trunk/
> Did you really want to delete trunk???
>
No. He's looking into it...
-bw
From mrs at apple.com Mon May 4 13:40:41 2009
From: mrs at apple.com (Mike Stump)
Date: Mon, 04 May 2009 18:40:41 -0000
Subject: [llvm-commits] [llvm] r70892 - /llvm/trunk/
Message-ID: <200905041840.n44Ief6K006984@zion.cs.uiuc.edu>
Author: mrs
Date: Mon May 4 13:40:41 2009
New Revision: 70892
URL: http://llvm.org/viewvc/llvm-project?rev=70892&view=rev
Log:
Restore minor deletion.
Added:
llvm/trunk/
- copied from r70890, llvm/trunk/
From stoklund at 2pi.dk Mon May 4 13:43:50 2009
From: stoklund at 2pi.dk (Jakob Stoklund Olesen)
Date: Mon, 4 May 2009 20:43:50 +0200
Subject: [llvm-commits] [llvm] r70892 - /llvm/trunk/
In-Reply-To: <200905041840.n44Ief6K006984@zion.cs.uiuc.edu>
References: <200905041840.n44Ief6K006984@zion.cs.uiuc.edu>
Message-ID:
On 04/05/2009, at 20.40, Mike Stump wrote:
> Author: mrs
> Date: Mon May 4 13:40:41 2009
> New Revision: 70892
>
> URL: http://llvm.org/viewvc/llvm-project?rev=70892&view=rev
> Log:
> Restore minor deletion.
>
> Added:
> llvm/trunk/
> - copied from r70890, llvm/trunk/
You owe me a new keyboard!
From collinwinter at google.com Mon May 4 13:53:42 2009
From: collinwinter at google.com (Collin Winter)
Date: Mon, 4 May 2009 11:53:42 -0700
Subject: [llvm-commits] Fix the CPP backend's handling of conditional
branches
Message-ID: <3c8293b60905041153k31a7cc43uca421d75feb5046f@mail.gmail.com>
Hi all,
At head, llc -march=cpp emits broken calls to BranchInst::Create for
conditional branches (llc succeeds, but g++ fails when compiling the
emitted C++ code). The attached patch fixes this and adds a test.
Thanks,
Collin Winter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cpp-condbranch.patch
Type: application/octet-stream
Size: 1840 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090504/07fc1274/attachment.obj
From asl at math.spbu.ru Mon May 4 14:10:39 2009
From: asl at math.spbu.ru (Anton Korobeynikov)
Date: Mon, 04 May 2009 19:10:39 -0000
Subject: [llvm-commits] [llvm] r70898 - in /llvm/trunk:
lib/Target/CppBackend/CPPBackend.cpp test/CodeGen/CPP/2009-05-04-CondBr.ll
Message-ID: <200905041910.n44JAdQ1008360@zion.cs.uiuc.edu>
Author: asl
Date: Mon May 4 14:10:38 2009
New Revision: 70898
URL: http://llvm.org/viewvc/llvm-project?rev=70898&view=rev
Log:
Fix code emission for conditional branches.
Patch by Collin Winter!
Added:
llvm/trunk/test/CodeGen/CPP/2009-05-04-CondBr.ll
Modified:
llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=70898&r1=70897&r2=70898&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original)
+++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Mon May 4 14:10:38 2009
@@ -1092,9 +1092,9 @@
const BranchInst* br = cast(I);
Out << "BranchInst::Create(" ;
if (br->getNumOperands() == 3 ) {
- Out << opNames[0] << ", "
+ Out << opNames[2] << ", "
<< opNames[1] << ", "
- << opNames[2] << ", ";
+ << opNames[0] << ", ";
} else if (br->getNumOperands() == 1) {
Out << opNames[0] << ", ";
Added: llvm/trunk/test/CodeGen/CPP/2009-05-04-CondBr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CPP/2009-05-04-CondBr.ll?rev=70898&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/CPP/2009-05-04-CondBr.ll (added)
+++ llvm/trunk/test/CodeGen/CPP/2009-05-04-CondBr.ll Mon May 4 14:10:38 2009
@@ -0,0 +1,28 @@
+; RUN: llvm-as < %s | llc -march=cpp -cppgen=program -f -o %t
+; RUN: grep "BranchInst::Create(label_if_then, label_if_end, int1_cmp, label_entry);" %t
+
+define i32 @some_func(i32 %a) nounwind {
+entry:
+ %retval = alloca i32 ; [#uses=2]
+ %a.addr = alloca i32 ; [#uses=8]
+ store i32 %a, i32* %a.addr
+ %tmp = load i32* %a.addr ; [#uses=1]
+ %inc = add i32 %tmp, 1 ; [#uses=1]
+ store i32 %inc, i32* %a.addr
+ %tmp1 = load i32* %a.addr ; [#uses=1]
+ %cmp = icmp slt i32 %tmp1, 3 ; [#uses=1]
+ br i1 %cmp, label %if.then, label %if.end
+
+if.then: ; preds = %entry
+ store i32 7, i32* %a.addr
+ br label %if.end
+
+if.end: ; preds = %if.then, %entry
+ %tmp2 = load i32* %a.addr ; [#uses=1]
+ %inc3 = add i32 %tmp2, 1 ; [#uses=1]
+ store i32 %inc3, i32* %a.addr
+ %tmp4 = load i32* %a.addr ; [#uses=1]
+ store i32 %tmp4, i32* %retval
+ %0 = load i32* %retval ; [#uses=1]
+ ret i32 %0
+}
From anton at korobeynikov.info Mon May 4 14:08:59 2009
From: anton at korobeynikov.info (Anton Korobeynikov)
Date: Mon, 04 May 2009 23:08:59 +0400
Subject: [llvm-commits] Fix the CPP backend's handling of conditional
branches
In-Reply-To: <3c8293b60905041153k31a7cc43uca421d75feb5046f@mail.gmail.com>
References: <3c8293b60905041153k31a7cc43uca421d75feb5046f@mail.gmail.com>
Message-ID: <1241464139.18321.31.camel@aslstation>
Hello, Collin
> At head, llc -march=cpp emits broken calls to BranchInst::Create for
> conditional branches (llc succeeds, but g++ fails when compiling the
> emitted C++ code). The attached patch fixes this and adds a test.
Applied, thanks!
--
With best regards, Anton Korobeynikov.
Faculty of Mathematics & Mechanics, Saint Petersburg State University.
From akyrtzi at gmail.com Mon May 4 14:23:47 2009
From: akyrtzi at gmail.com (Argiris Kirtzidis)
Date: Mon, 04 May 2009 19:23:47 -0000
Subject: [llvm-commits] [llvm] r70900 -
/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
Message-ID: <200905041923.n44JNl98008905@zion.cs.uiuc.edu>
Author: akirtzidis
Date: Mon May 4 14:23:45 2009
New Revision: 70900
URL: http://llvm.org/viewvc/llvm-project?rev=70900&view=rev
Log:
Restore a comment.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=70900&r1=70899&r2=70900&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Mon May 4 14:23:45 2009
@@ -3262,6 +3262,8 @@
// Assumes in correct section after the entry point.
EmitLabel("func_begin", ++SubprogramCount);
+ // Emit label for the implicitly defined dbg.stoppoint at the start of
+ // the function.
DebugLoc FDL = MF->getDefaultDebugLoc();
if (!FDL.isUnknown()) {
DebugLocTuple DLT = MF->getDebugLocTuple(FDL);
From gohman at apple.com Mon May 4 14:50:34 2009
From: gohman at apple.com (Dan Gohman)
Date: Mon, 04 May 2009 19:50:34 -0000
Subject: [llvm-commits] [llvm] r70902 - in /llvm/trunk:
lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-tailcall.ll
Message-ID: <200905041950.n44JoYld010013@zion.cs.uiuc.edu>
Author: djg
Date: Mon May 4 14:50:33 2009
New Revision: 70902
URL: http://llvm.org/viewvc/llvm-project?rev=70902&view=rev
Log:
X86FastISel doesn't support the -tailcallopt ABI.
Added:
llvm/trunk/test/CodeGen/X86/fast-isel-tailcall.ll
Modified:
llvm/trunk/lib/Target/X86/X86FastISel.cpp
Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=70902&r1=70901&r2=70902&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Mon May 4 14:50:33 2009
@@ -30,6 +30,7 @@
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
+#include "llvm/Target/TargetOptions.h"
using namespace llvm;
namespace {
@@ -1115,6 +1116,11 @@
CC != CallingConv::X86_FastCall)
return false;
+ // On X86, -tailcallopt changes the fastcc ABI. FastISel doesn't
+ // handle this for now.
+ if (CC == CallingConv::Fast && PerformTailCallOpt)
+ return false;
+
// Let SDISel handle vararg functions.
const PointerType *PT = cast(CS.getCalledValue()->getType());
const FunctionType *FTy = cast(PT->getElementType());
Added: llvm/trunk/test/CodeGen/X86/fast-isel-tailcall.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-tailcall.ll?rev=70902&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel-tailcall.ll (added)
+++ llvm/trunk/test/CodeGen/X86/fast-isel-tailcall.ll Mon May 4 14:50:33 2009
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | llc -fast-isel -tailcallopt -march=x86 | not grep add
+; PR4154
+
+; On x86, -tailcallopt changes the ABI so the caller shouldn't readjust
+; the stack pointer after the call in this code.
+
+define i32 @stub(i8* %t0) nounwind {
+entry:
+ %t1 = load i32* inttoptr (i32 139708680 to i32*) ; [#uses=1]
+ %t2 = bitcast i8* %t0 to i32 (i32)* ; [#uses=1]
+ %t3 = call fastcc i32 %t2(i32 %t1) ; [#uses=1]
+ ret i32 %t3
+}
From gohman at apple.com Mon May 4 17:02:23 2009
From: gohman at apple.com (Dan Gohman)
Date: Mon, 04 May 2009 22:02:23 -0000
Subject: [llvm-commits] [llvm] r70919 - in /llvm/trunk/lib:
Analysis/ScalarEvolution.cpp Transforms/Scalar/LoopStrengthReduce.cpp
Message-ID: <200905042202.n44M2NXr014656@zion.cs.uiuc.edu>
Author: djg
Date: Mon May 4 17:02:23 2009
New Revision: 70919
URL: http://llvm.org/viewvc/llvm-project?rev=70919&view=rev
Log:
Constify a bunch of SCEV-using code.
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=70919&r1=70918&r2=70919&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 4 17:02:23 2009
@@ -650,25 +650,25 @@
"This is not a conversion to a SCEVable type!");
Ty = getEffectiveSCEVType(Ty);
- if (SCEVConstant *SC = dyn_cast(Op))
+ if (const SCEVConstant *SC = dyn_cast(Op))
return getUnknown(
ConstantExpr::getTrunc(SC->getValue(), Ty));
// trunc(trunc(x)) --> trunc(x)
- if (SCEVTruncateExpr *ST = dyn_cast(Op))
+ if (const SCEVTruncateExpr *ST = dyn_cast(Op))
return getTruncateExpr(ST->getOperand(), Ty);
// trunc(sext(x)) --> sext(x) if widening or trunc(x) if narrowing
- if (SCEVSignExtendExpr *SS = dyn_cast(Op))
+ if (const SCEVSignExtendExpr *SS = dyn_cast(Op))
return getTruncateOrSignExtend(SS->getOperand(), Ty);
// trunc(zext(x)) --> zext(x) if widening or trunc(x) if narrowing
- if (SCEVZeroExtendExpr *SZ = dyn_cast(Op))
+ 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 (SCEVAddRecExpr *AddRec = dyn_cast(Op)) {
+ if (const SCEVAddRecExpr *AddRec = dyn_cast(Op)) {
std::vector Operands;
for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i)
// FIXME: This should allow truncation of other expression types!
@@ -693,7 +693,7 @@
"This is not a conversion to a SCEVable type!");
Ty = getEffectiveSCEVType(Ty);
- if (SCEVConstant *SC = dyn_cast(Op)) {
+ if (const SCEVConstant *SC = dyn_cast(Op)) {
const Type *IntTy = getEffectiveSCEVType(Ty);
Constant *C = ConstantExpr::getZExt(SC->getValue(), IntTy);
if (IntTy != Ty) C = ConstantExpr::getIntToPtr(C, Ty);
@@ -701,14 +701,14 @@
}
// zext(zext(x)) --> zext(x)
- if (SCEVZeroExtendExpr *SZ = dyn_cast(Op))
+ if (const SCEVZeroExtendExpr *SZ = dyn_cast(Op))
return getZeroExtendExpr(SZ->getOperand(), Ty);
// If the input value is a chrec scev, and we can prove that the value
// did not overflow the old, smaller, value, we can zero extend all of the
// operands (often constants). This allows analysis of something like
// this: for (unsigned char X = 0; X < 100; ++X) { int Y = X; }
- if (SCEVAddRecExpr *AR = dyn_cast(Op))
+ if (const SCEVAddRecExpr *AR = dyn_cast(Op))
if (AR->isAffine()) {
// Check whether the backedge-taken count is SCEVCouldNotCompute.
// Note that this serves two purposes: It filters out loops that are
@@ -778,7 +778,7 @@
"This is not a conversion to a SCEVable type!");
Ty = getEffectiveSCEVType(Ty);
- if (SCEVConstant *SC = dyn_cast(Op)) {
+ if (const SCEVConstant *SC = dyn_cast(Op)) {
const Type *IntTy = getEffectiveSCEVType(Ty);
Constant *C = ConstantExpr::getSExt(SC->getValue(), IntTy);
if (IntTy != Ty) C = ConstantExpr::getIntToPtr(C, Ty);
@@ -786,14 +786,14 @@
}
// sext(sext(x)) --> sext(x)
- if (SCEVSignExtendExpr *SS = dyn_cast(Op))
+ if (const SCEVSignExtendExpr *SS = dyn_cast(Op))
return getSignExtendExpr(SS->getOperand(), Ty);
// If the input value is a chrec scev, and we can prove that the value
// did not overflow the old, smaller, value, we can sign extend all of the
// operands (often constants). This allows analysis of something like
// this: for (signed char X = 0; X < 100; ++X) { int Y = X; }
- if (SCEVAddRecExpr *AR = dyn_cast(Op))
+ if (const SCEVAddRecExpr *AR = dyn_cast(Op))
if (AR->isAffine()) {
// Check whether the backedge-taken count is SCEVCouldNotCompute.
// Note that this serves two purposes: It filters out loops that are
@@ -850,10 +850,10 @@
// If there are any constants, fold them together.
unsigned Idx = 0;
- if (SCEVConstant *LHSC = dyn_cast(Ops[0])) {
+ if (const SCEVConstant *LHSC = dyn_cast(Ops[0])) {
++Idx;
assert(Idx < Ops.size());
- while (SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
+ while (const SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
// We found two constants, fold them together!
ConstantInt *Fold = ConstantInt::get(LHSC->getValue()->getValue() +
RHSC->getValue()->getValue());
@@ -896,7 +896,7 @@
// If there are add operands they would be next.
if (Idx < Ops.size()) {
bool DeletedAdd = false;
- while (SCEVAddExpr *Add = dyn_cast(Ops[Idx])) {
+ while (const SCEVAddExpr *Add = dyn_cast(Ops[Idx])) {
// If we have an add, expand the add operands onto the end of the operands
// list.
Ops.insert(Ops.end(), Add->op_begin(), Add->op_end());
@@ -1075,11 +1075,11 @@
// If there are any constants, fold them together.
unsigned Idx = 0;
- if (SCEVConstant *LHSC = dyn_cast(Ops[0])) {
+ if (const SCEVConstant *LHSC = dyn_cast(Ops[0])) {
// C1*(C2+V) -> C1*C2 + C1*V
if (Ops.size() == 2)
- if (SCEVAddExpr *Add = dyn_cast(Ops[1]))
+ if (const SCEVAddExpr *Add = dyn_cast(Ops[1]))
if (Add->getNumOperands() == 2 &&
isa(Add->getOperand(0)))
return getAddExpr(getMulExpr(LHSC, Add->getOperand(0)),
@@ -1087,7 +1087,7 @@
++Idx;
- while (SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
+ while (const SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
// We found two constants, fold them together!
ConstantInt *Fold = ConstantInt::get(LHSC->getValue()->getValue() *
RHSC->getValue()->getValue());
@@ -1117,7 +1117,7 @@
// If there are mul operands inline them all into this expression.
if (Idx < Ops.size()) {
bool DeletedMul = false;
- while (SCEVMulExpr *Mul = dyn_cast(Ops[Idx])) {
+ while (const SCEVMulExpr *Mul = dyn_cast(Ops[Idx])) {
// If we have an mul, expand the mul operands onto the end of the operands
// list.
Ops.insert(Ops.end(), Mul->op_begin(), Mul->op_end());
@@ -1225,11 +1225,11 @@
}
SCEVHandle ScalarEvolution::getUDivExpr(const SCEVHandle &LHS, const SCEVHandle &RHS) {
- if (SCEVConstant *RHSC = dyn_cast(RHS)) {
+ if (const SCEVConstant *RHSC = dyn_cast(RHS)) {
if (RHSC->getValue()->equalsInt(1))
return LHS; // X udiv 1 --> x
- if (SCEVConstant *LHSC = dyn_cast(LHS)) {
+ if (const SCEVConstant *LHSC = dyn_cast(LHS)) {
Constant *LHSCV = LHSC->getValue();
Constant *RHSCV = RHSC->getValue();
return getUnknown(ConstantExpr::getUDiv(LHSCV, RHSCV));
@@ -1250,7 +1250,7 @@
const SCEVHandle &Step, const Loop *L) {
std::vector Operands;
Operands.push_back(Start);
- if (SCEVAddRecExpr *StepChrec = dyn_cast(Step))
+ if (const SCEVAddRecExpr *StepChrec = dyn_cast(Step))
if (StepChrec->getLoop() == L) {
Operands.insert(Operands.end(), StepChrec->op_begin(),
StepChrec->op_end());
@@ -1273,7 +1273,7 @@
}
// Canonicalize nested AddRecs in by nesting them in order of loop depth.
- if (SCEVAddRecExpr *NestedAR = dyn_cast(Operands[0])) {
+ if (const SCEVAddRecExpr *NestedAR = dyn_cast(Operands[0])) {
const Loop* NestedLoop = NestedAR->getLoop();
if (L->getLoopDepth() < NestedLoop->getLoopDepth()) {
std::vector NestedOperands(NestedAR->op_begin(),
@@ -1309,10 +1309,10 @@
// If there are any constants, fold them together.
unsigned Idx = 0;
- if (SCEVConstant *LHSC = dyn_cast(Ops[0])) {
+ if (const SCEVConstant *LHSC = dyn_cast(Ops[0])) {
++Idx;
assert(Idx < Ops.size());
- while (SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
+ while (const SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
// We found two constants, fold them together!
ConstantInt *Fold = ConstantInt::get(
APIntOps::smax(LHSC->getValue()->getValue(),
@@ -1340,7 +1340,7 @@
// onto our operand list, and recurse to simplify.
if (Idx < Ops.size()) {
bool DeletedSMax = false;
- while (SCEVSMaxExpr *SMax = dyn_cast(Ops[Idx])) {
+ while (const SCEVSMaxExpr *SMax = dyn_cast(Ops[Idx])) {
Ops.insert(Ops.end(), SMax->op_begin(), SMax->op_end());
Ops.erase(Ops.begin()+Idx);
DeletedSMax = true;
@@ -1389,10 +1389,10 @@
// If there are any constants, fold them together.
unsigned Idx = 0;
- if (SCEVConstant *LHSC = dyn_cast(Ops[0])) {
+ if (const SCEVConstant *LHSC = dyn_cast(Ops[0])) {
++Idx;
assert(Idx < Ops.size());
- while (SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
+ while (const SCEVConstant *RHSC = dyn_cast(Ops[Idx])) {
// We found two constants, fold them together!
ConstantInt *Fold = ConstantInt::get(
APIntOps::umax(LHSC->getValue()->getValue(),
@@ -1420,7 +1420,7 @@
// onto our operand list, and recurse to simplify.
if (Idx < Ops.size()) {
bool DeletedUMax = false;
- while (SCEVUMaxExpr *UMax = dyn_cast(Ops[Idx])) {
+ while (const SCEVUMaxExpr *UMax = dyn_cast(Ops[Idx])) {
Ops.insert(Ops.end(), UMax->op_begin(), UMax->op_end());
Ops.erase(Ops.begin()+Idx);
DeletedUMax = true;
@@ -1580,7 +1580,7 @@
/// getNegativeSCEV - Return a SCEV corresponding to -V = -1*V
///
SCEVHandle ScalarEvolution::getNegativeSCEV(const SCEVHandle &V) {
- if (SCEVConstant *VC = dyn_cast(V))
+ if (const SCEVConstant *VC = dyn_cast(V))
return getUnknown(ConstantExpr::getNeg(VC->getValue()));
const Type *Ty = V->getType();
@@ -1590,7 +1590,7 @@
/// getNotSCEV - Return a SCEV corresponding to ~V = -1-V
SCEVHandle ScalarEvolution::getNotSCEV(const SCEVHandle &V) {
- if (SCEVConstant *VC = dyn_cast(V))
+ if (const SCEVConstant *VC = dyn_cast(V))
return getUnknown(ConstantExpr::getNot(VC->getValue()));
const Type *Ty = V->getType();
@@ -1690,7 +1690,7 @@
// If the value coming around the backedge is an add with the symbolic
// value we just inserted, then we found a simple induction variable!
- if (SCEVAddExpr *Add = dyn_cast(BEValue)) {
+ if (const SCEVAddExpr *Add = dyn_cast(BEValue)) {
// If there is a single occurrence of the symbolic value, replace it
// with a recurrence.
unsigned FoundIndex = Add->getNumOperands();
@@ -1726,7 +1726,8 @@
return PHISCEV;
}
}
- } else if (SCEVAddRecExpr *AddRec = dyn_cast(BEValue)) {
+ } else if (const SCEVAddRecExpr *AddRec =
+ dyn_cast(BEValue)) {
// Otherwise, this could be a loop like this:
// i = 0; for (j = 1; ..; ++j) { .... i = j; }
// In this case, j = {1,+,1} and BEValue is j.
@@ -1765,26 +1766,26 @@
/// 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) {
- if (SCEVConstant *C = dyn_cast(S))
+ if (const SCEVConstant *C = dyn_cast(S))
return C->getValue()->getValue().countTrailingZeros();
- if (SCEVTruncateExpr *T = dyn_cast(S))
+ if (const SCEVTruncateExpr *T = dyn_cast(S))
return std::min(GetMinTrailingZeros(T->getOperand(), SE),
(uint32_t)SE.getTypeSizeInBits(T->getType()));
- if (SCEVZeroExtendExpr *E = dyn_cast(S)) {
+ if (const SCEVZeroExtendExpr *E = dyn_cast(S)) {
uint32_t OpRes = GetMinTrailingZeros(E->getOperand(), SE);
return OpRes == SE.getTypeSizeInBits(E->getOperand()->getType()) ?
SE.getTypeSizeInBits(E->getOperand()->getType()) : OpRes;
}
- if (SCEVSignExtendExpr *E = dyn_cast(S)) {
+ if (const SCEVSignExtendExpr *E = dyn_cast(S)) {
uint32_t OpRes = GetMinTrailingZeros(E->getOperand(), SE);
return OpRes == SE.getTypeSizeInBits(E->getOperand()->getType()) ?
SE.getTypeSizeInBits(E->getOperand()->getType()) : OpRes;
}
- if (SCEVAddExpr *A = dyn_cast(S)) {
+ if (const SCEVAddExpr *A = dyn_cast(S)) {
// The result is the min of all operands results.
uint32_t MinOpRes = GetMinTrailingZeros(A->getOperand(0), SE);
for (unsigned i = 1, e = A->getNumOperands(); MinOpRes && i != e; ++i)
@@ -1792,7 +1793,7 @@
return MinOpRes;
}
- if (SCEVMulExpr *M = dyn_cast(S)) {
+ 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());
@@ -1803,7 +1804,7 @@
return SumOpRes;
}
- if (SCEVAddRecExpr *A = dyn_cast(S)) {
+ if (const SCEVAddRecExpr *A = dyn_cast(S)) {
// The result is the min of all operands results.
uint32_t MinOpRes = GetMinTrailingZeros(A->getOperand(0), SE);
for (unsigned i = 1, e = A->getNumOperands(); MinOpRes && i != e; ++i)
@@ -1811,7 +1812,7 @@
return MinOpRes;
}
- if (SCEVSMaxExpr *M = dyn_cast(S)) {
+ if (const SCEVSMaxExpr *M = dyn_cast(S)) {
// The result is the min of all operands results.
uint32_t MinOpRes = GetMinTrailingZeros(M->getOperand(0), SE);
for (unsigned i = 1, e = M->getNumOperands(); MinOpRes && i != e; ++i)
@@ -1819,7 +1820,7 @@
return MinOpRes;
}
- if (SCEVUMaxExpr *M = dyn_cast(S)) {
+ if (const SCEVUMaxExpr *M = dyn_cast(S)) {
// The result is the min of all operands results.
uint32_t MinOpRes = GetMinTrailingZeros(M->getOperand(0), SE);
for (unsigned i = 1, e = M->getNumOperands(); MinOpRes && i != e; ++i)
@@ -2224,8 +2225,8 @@
// If we have a comparison of a chrec against a constant, try to use value
// ranges to answer this query.
- if (SCEVConstant *RHSC = dyn_cast(RHS))
- if (SCEVAddRecExpr *AddRec = dyn_cast(LHS))
+ if (const SCEVConstant *RHSC = dyn_cast(RHS))
+ if (const SCEVAddRecExpr *AddRec = dyn_cast(LHS))
if (AddRec->getLoop() == L) {
// Form the comparison range using the constant of the correct type so
// that the ConstantRange class knows to do a signed or unsigned
@@ -2610,7 +2611,7 @@
// If this instruction is evolved from a constant-evolving PHI, compute the
// exit value from the loop without using SCEVs.
- if (SCEVUnknown *SU = dyn_cast(V)) {
+ if (const SCEVUnknown *SU = dyn_cast(V)) {
if (Instruction *I = dyn_cast(SU->getValue())) {
const Loop *LI = (*this->LI)[I->getParent()];
if (LI && LI->getParentLoop() == L) // Looking for loop exit value.
@@ -2621,7 +2622,7 @@
// count. If so, we may be able to force computation of the exit
// value.
SCEVHandle BackedgeTakenCount = getBackedgeTakenCount(LI);
- if (SCEVConstant *BTCC =
+ if (const SCEVConstant *BTCC =
dyn_cast(BackedgeTakenCount)) {
// Okay, we know how many times the containing loop executes. If
// this is a constant evolving PHI node, get the final value at
@@ -2652,7 +2653,7 @@
return V;
SCEVHandle OpV = getSCEVAtScope(getSCEV(Op), L);
- if (SCEVConstant *SC = dyn_cast(OpV)) {
+ if (const SCEVConstant *SC = dyn_cast(OpV)) {
Constant *C = SC->getValue();
if (C->getType() != Op->getType())
C = ConstantExpr::getCast(CastInst::getCastOpcode(C, false,
@@ -2660,7 +2661,7 @@
false),
C, Op->getType());
Operands.push_back(C);
- } else if (SCEVUnknown *SU = dyn_cast(OpV)) {
+ } else if (const SCEVUnknown *SU = dyn_cast(OpV)) {
if (Constant *C = dyn_cast(SU->getValue())) {
if (C->getType() != Op->getType())
C =
@@ -2692,7 +2693,7 @@
return V;
}
- if (SCEVCommutativeExpr *Comm = dyn_cast(V)) {
+ if (const SCEVCommutativeExpr *Comm = dyn_cast(V)) {
// Avoid performing the look-up in the common case where the specified
// expression has no loop-variant portions.
for (unsigned i = 0, e = Comm->getNumOperands(); i != e; ++i) {
@@ -2724,7 +2725,7 @@
return Comm;
}
- if (SCEVUDivExpr *Div = dyn_cast(V)) {
+ if (const SCEVUDivExpr *Div = dyn_cast(V)) {
SCEVHandle LHS = getSCEVAtScope(Div->getLHS(), L);
if (LHS == UnknownValue) return LHS;
SCEVHandle RHS = getSCEVAtScope(Div->getRHS(), L);
@@ -2736,7 +2737,7 @@
// If this is a loop recurrence for a loop that does not contain L, then we
// are dealing with the final value computed by the loop.
- if (SCEVAddRecExpr *AddRec = dyn_cast(V)) {
+ if (const SCEVAddRecExpr *AddRec = dyn_cast(V)) {
if (!L || !AddRec->getLoop()->contains(L->getHeader())) {
// To evaluate this recurrence, we need to know how many times the AddRec
// loop iterates. Compute this now.
@@ -2749,7 +2750,7 @@
return UnknownValue;
}
- if (SCEVZeroExtendExpr *Cast = dyn_cast(V)) {
+ if (const SCEVZeroExtendExpr *Cast = dyn_cast(V)) {
SCEVHandle Op = getSCEVAtScope(Cast->getOperand(), L);
if (Op == UnknownValue) return Op;
if (Op == Cast->getOperand())
@@ -2757,7 +2758,7 @@
return getZeroExtendExpr(Op, Cast->getType());
}
- if (SCEVSignExtendExpr *Cast = dyn_cast(V)) {
+ if (const SCEVSignExtendExpr *Cast = dyn_cast(V)) {
SCEVHandle Op = getSCEVAtScope(Cast->getOperand(), L);
if (Op == UnknownValue) return Op;
if (Op == Cast->getOperand())
@@ -2765,7 +2766,7 @@
return getSignExtendExpr(Op, Cast->getType());
}
- if (SCEVTruncateExpr *Cast = dyn_cast(V)) {
+ if (const SCEVTruncateExpr *Cast = dyn_cast(V)) {
SCEVHandle Op = getSCEVAtScope(Cast->getOperand(), L);
if (Op == UnknownValue) return Op;
if (Op == Cast->getOperand())
@@ -2903,7 +2904,7 @@
/// value to zero will execute. If not computable, return UnknownValue
SCEVHandle ScalarEvolution::HowFarToZero(SCEV *V, const Loop *L) {
// If the value is a constant
- if (SCEVConstant *C = dyn_cast(V)) {
+ if (const SCEVConstant *C = dyn_cast(V)) {
// If the value is already zero, the branch will execute zero times.
if (C->getValue()->isZero()) return C;
return UnknownValue; // Otherwise it will loop infinitely.
@@ -2931,7 +2932,7 @@
SCEVHandle Step = getSCEVAtScope(AddRec->getOperand(1), L->getParentLoop());
- if (SCEVConstant *StepC = dyn_cast(Step)) {
+ if (const SCEVConstant *StepC = dyn_cast(Step)) {
// For now we handle only constant steps.
// First, handle unitary steps.
@@ -2941,7 +2942,7 @@
return Start; // N = Start (as unsigned)
// Then, try to solve the above equation provided that Start is constant.
- if (SCEVConstant *StartC = dyn_cast(Start))
+ if (const SCEVConstant *StartC = dyn_cast(Start))
return SolveLinEquationWithOverflow(StepC->getValue()->getValue(),
-StartC->getValue()->getValue(),
*this);
@@ -2988,7 +2989,7 @@
// If the value is a constant, check to see if it is known to be non-zero
// already. If so, the backedge will execute zero times.
- if (SCEVConstant *C = dyn_cast(V)) {
+ if (const SCEVConstant *C = dyn_cast(V)) {
if (!C->getValue()->isNullValue())
return getIntegerSCEV(0, C->getType());
return UnknownValue; // Otherwise it will loop infinitely.
@@ -3232,12 +3233,13 @@
return SE.getCouldNotCompute();
// If the start is a non-zero constant, shift the range to simplify things.
- if (SCEVConstant *SC = dyn_cast(getStart()))
+ if (const SCEVConstant *SC = dyn_cast(getStart()))
if (!SC->getValue()->isZero()) {
std::vector Operands(op_begin(), op_end());
Operands[0] = SE.getIntegerSCEV(0, SC->getType());
SCEVHandle Shifted = SE.getAddRecExpr(Operands, getLoop());
- if (SCEVAddRecExpr *ShiftedAddRec = dyn_cast(Shifted))
+ if (const SCEVAddRecExpr *ShiftedAddRec =
+ dyn_cast(Shifted))
return ShiftedAddRec->getNumIterationsInRange(
Range.subtract(SC->getValue()->getValue()), SE);
// This is strange and shouldn't happen.
Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=70919&r1=70918&r2=70919&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon May 4 17:02:23 2009
@@ -321,7 +321,7 @@
// for a nested AddRecExpr.
if (const SCEVAddExpr *AE = dyn_cast(SH)) {
for (unsigned i = 0, e = AE->getNumOperands(); i != e; ++i)
- if (SCEVAddRecExpr *AddRec =
+ if (const SCEVAddRecExpr *AddRec =
dyn_cast(AE->getOperand(i))) {
if (AddRec->getLoop() == L)
TheAddRec = SE->getAddExpr(AddRec, TheAddRec);
@@ -1400,8 +1400,8 @@
// Iterate through the uses to find conditions that automatically rule out
// full-lsr mode.
for (unsigned i = 0, e = UsersToProcess.size(); i != e; ) {
- SCEV *Base = UsersToProcess[i].Base;
- SCEV *Imm = UsersToProcess[i].Imm;
+ const SCEV *Base = UsersToProcess[i].Base;
+ const SCEV *Imm = UsersToProcess[i].Imm;
// If any users have a loop-variant component, they can't be fully
// strength-reduced.
if (Imm && !Imm->isLoopInvariant(L))
@@ -1410,7 +1410,7 @@
// the two Imm values can't be folded into the address, full
// strength reduction would increase register pressure.
do {
- SCEV *CurImm = UsersToProcess[i].Imm;
+ const SCEV *CurImm = UsersToProcess[i].Imm;
if ((CurImm || Imm) && CurImm != Imm) {
if (!CurImm) CurImm = SE->getIntegerSCEV(0, Stride->getType());
if (!Imm) Imm = SE->getIntegerSCEV(0, Stride->getType());
From sabre at nondot.org Mon May 4 17:10:06 2009
From: sabre at nondot.org (Chris Lattner)
Date: Mon, 04 May 2009 22:10:06 -0000
Subject: [llvm-commits] [llvm] r70921 - in /llvm/trunk:
include/llvm/CodeGen/SelectionDAG.h
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
Message-ID: <200905042210.n44MA6ZB014912@zion.cs.uiuc.edu>
Author: lattner
Date: Mon May 4 17:10:05 2009
New Revision: 70921
URL: http://llvm.org/viewvc/llvm-project?rev=70921&view=rev
Log:
Make DBG_STOPPOINT nodes, and therefore DBG_LABEL labels, get a DebugLoc, so that it
shows up in -print-machineinstrs. This doesn't appear to affect anything, but it was
weird for some DBG_LABELs to have DebugLocs but not all of them.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=70921&r1=70920&r2=70921&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Mon May 4 17:10:05 2009
@@ -302,8 +302,8 @@
SDValue getArgFlags(ISD::ArgFlagsTy Flags);
SDValue getValueType(MVT);
SDValue getRegister(unsigned Reg, MVT VT);
- SDValue getDbgStopPoint(SDValue Root, unsigned Line, unsigned Col,
- Value *CU);
+ SDValue getDbgStopPoint(DebugLoc DL, SDValue Root,
+ unsigned Line, unsigned Col, Value *CU);
SDValue getLabel(unsigned Opcode, DebugLoc dl, SDValue Root,
unsigned LabelID);
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=70921&r1=70920&r2=70921&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon May 4 17:10:05 2009
@@ -1273,11 +1273,12 @@
return SDValue(N, 0);
}
-SDValue SelectionDAG::getDbgStopPoint(SDValue Root,
+SDValue SelectionDAG::getDbgStopPoint(DebugLoc DL, SDValue Root,
unsigned Line, unsigned Col,
Value *CU) {
SDNode *N = NodeAllocator.Allocate();
new (N) DbgStopPointSDNode(Root, Line, Col, CU);
+ N->setDebugLoc(DL);
AllNodes.push_back(N);
return SDValue(N, 0);
}
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=70921&r1=70920&r2=70921&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon May 4 17:10:05 2009
@@ -3889,15 +3889,16 @@
DbgStopPointInst &SPI = cast(I);
if (DIDescriptor::ValidDebugInfo(SPI.getContext(), OptLevel)) {
MachineFunction &MF = DAG.getMachineFunction();
+ DICompileUnit CU(cast(SPI.getContext()));
+ DebugLoc Loc = DebugLoc::get(MF.getOrCreateDebugLocID(CU.getGV(),
+ SPI.getLine(), SPI.getColumn()));
+ setCurDebugLoc(Loc);
+
if (OptLevel == CodeGenOpt::None)
- DAG.setRoot(DAG.getDbgStopPoint(getRoot(),
+ DAG.setRoot(DAG.getDbgStopPoint(Loc, getRoot(),
SPI.getLine(),
SPI.getColumn(),
SPI.getContext()));
- DICompileUnit CU(cast(SPI.getContext()));
- unsigned idx = MF.getOrCreateDebugLocID(CU.getGV(),
- SPI.getLine(), SPI.getColumn());
- setCurDebugLoc(DebugLoc::get(idx));
}
return 0;
}
From gohman at apple.com Mon May 4 17:20:30 2009
From: gohman at apple.com (Dan Gohman)
Date: Mon, 04 May 2009 22:20:30 -0000
Subject: [llvm-commits] [llvm] r70924 -
/llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Message-ID: <200905042220.n44MKUKL015240@zion.cs.uiuc.edu>
Author: djg
Date: Mon May 4 17:20:30 2009
New Revision: 70924
URL: http://llvm.org/viewvc/llvm-project?rev=70924&view=rev
Log:
Fix doxygen comment syntax.
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=70924&r1=70923&r2=70924&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 4 17:20:30 2009
@@ -1544,7 +1544,7 @@
return UnknownValue;
}
-// hasSCEV - Return true if the SCEV for this value has already been
+/// hasSCEV - Return true if the SCEV for this value has already been
/// computed.
bool ScalarEvolution::hasSCEV(Value *V) const {
return Scalars.count(V);
From gohman at apple.com Mon May 4 17:23:19 2009
From: gohman at apple.com (Dan Gohman)
Date: Mon, 04 May 2009 22:23:19 -0000
Subject: [llvm-commits] [llvm] r70925 -
/llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Message-ID: <200905042223.n44MNJAZ015316@zion.cs.uiuc.edu>
Author: djg
Date: Mon May 4 17:23:18 2009
New Revision: 70925
URL: http://llvm.org/viewvc/llvm-project?rev=70925&view=rev
Log:
Fix an 80-column violation.
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=70925&r1=70924&r2=70925&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 4 17:23:18 2009
@@ -1224,7 +1224,8 @@
return Result;
}
-SCEVHandle ScalarEvolution::getUDivExpr(const SCEVHandle &LHS, const SCEVHandle &RHS) {
+SCEVHandle ScalarEvolution::getUDivExpr(const SCEVHandle &LHS,
+ const SCEVHandle &RHS) {
if (const SCEVConstant *RHSC = dyn_cast(RHS)) {
if (RHSC->getValue()->equalsInt(1))
return LHS; // X udiv 1 --> x
From gohman at apple.com Mon May 4 17:30:44 2009
From: gohman at apple.com (Dan Gohman)
Date: Mon, 04 May 2009 22:30:44 -0000
Subject: [llvm-commits] [llvm] r70927 - in /llvm/trunk:
include/llvm/Analysis/ScalarEvolution.h
include/llvm/Transforms/Utils/BasicBlockUtils.h
include/llvm/Transforms/Utils/Local.h lib/Analysis/ScalarEvolution.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
lib/Transforms/Scalar/LoopDeletion.cpp
lib/Transforms/Scalar/LoopStrengthReduce.cpp
lib/Transforms/Utils/BasicBlockUtils.cpp lib/Transforms/Utils/Local.cpp
Message-ID: <200905042230.n44MUjMo015556@zion.cs.uiuc.edu>
Author: djg
Date: Mon May 4 17:30:44 2009
New Revision: 70927
URL: http://llvm.org/viewvc/llvm-project?rev=70927&view=rev
Log:
Re-apply 70645, converting ScalarEvolution to use
CallbackVH, with fixes. allUsesReplacedWith need to
walk the def-use chains and invalidate all users of a
value that is replaced. SCEVs of users need to be
recalcualted even if the new value is equivalent. Also,
make forgetLoopPHIs walk def-use chains, since any
SCEV that depends on a PHI should be recalculated when
more information about that PHI becomes available.
Modified:
llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/trunk/include/llvm/Transforms/Utils/Local.h
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/trunk/lib/Transforms/Scalar/LoopDeletion.cpp
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/trunk/lib/Transforms/Utils/Local.cpp
Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=70927&r1=70926&r2=70927&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon May 4 17:30:44 2009
@@ -24,6 +24,7 @@
#include "llvm/Pass.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/ValueHandle.h"
#include
namespace llvm {
@@ -140,13 +141,23 @@
static bool classof(const SCEV *S);
};
+ /// SCEVCallbackVH - A CallbackVH to arrange for ScalarEvolution to be
+ /// notified whenever a Value is deleted.
+ class SCEVCallbackVH : public CallbackVH {
+ ScalarEvolution *SE;
+ virtual void deleted();
+ virtual void allUsesReplacedWith(Value *New);
+ public:
+ SCEVCallbackVH(Value *V, ScalarEvolution *SE = 0);
+ };
+
/// SCEVHandle - This class is used to maintain the SCEV object's refcounts,
/// freeing the objects when the last reference is dropped.
class SCEVHandle {
- SCEV *S;
+ const SCEV *S;
SCEVHandle(); // DO NOT IMPLEMENT
public:
- SCEVHandle(const SCEV *s) : S(const_cast(s)) {
+ SCEVHandle(const SCEV *s) : S(s) {
assert(S && "Cannot create a handle to a null SCEV!");
S->addRef();
}
@@ -155,13 +166,13 @@
}
~SCEVHandle() { S->dropRef(); }
- operator SCEV*() const { return S; }
+ operator const SCEV*() const { return S; }
- SCEV &operator*() const { return *S; }
- SCEV *operator->() const { return S; }
+ const SCEV &operator*() const { return *S; }
+ const SCEV *operator->() const { return S; }
- bool operator==(SCEV *RHS) const { return S == RHS; }
- bool operator!=(SCEV *RHS) const { return S != RHS; }
+ bool operator==(const SCEV *RHS) const { return S == RHS; }
+ bool operator!=(const SCEV *RHS) const { return S != RHS; }
const SCEVHandle &operator=(SCEV *RHS) {
if (S != RHS) {
@@ -184,7 +195,7 @@
template struct simplify_type;
template<> struct simplify_type {
- typedef SCEV* SimpleType;
+ typedef const SCEV* SimpleType;
static SimpleType getSimplifiedValue(const SCEVHandle &Node) {
return Node;
}
@@ -197,6 +208,8 @@
/// they must ask this class for services.
///
class ScalarEvolution : public FunctionPass {
+ friend class SCEVCallbackVH;
+
/// F - The function we are analyzing.
///
Function *F;
@@ -215,7 +228,7 @@
/// Scalars - This is a cache of the scalars we have analyzed so far.
///
- std::map Scalars;
+ std::map Scalars;
/// BackedgeTakenInfo - Information about the backedge-taken count
/// of a loop. This currently inclues an exact count and a maximum count.
@@ -232,7 +245,7 @@
/*implicit*/ BackedgeTakenInfo(SCEVHandle exact) :
Exact(exact), Max(exact) {}
- /*implicit*/ BackedgeTakenInfo(SCEV *exact) :
+ /*implicit*/ BackedgeTakenInfo(const SCEV *exact) :
Exact(exact), Max(exact) {}
BackedgeTakenInfo(SCEVHandle exact, SCEVHandle max) :
@@ -302,18 +315,18 @@
/// HowFarToZero - Return the number of times a backedge comparing the
/// specified value to zero will execute. If not computable, return
/// UnknownValue.
- SCEVHandle HowFarToZero(SCEV *V, const Loop *L);
+ SCEVHandle HowFarToZero(const SCEV *V, const Loop *L);
/// HowFarToNonZero - Return the number of times a backedge checking the
/// specified value for nonzero will execute. If not computable, return
/// UnknownValue.
- SCEVHandle HowFarToNonZero(SCEV *V, const Loop *L);
+ SCEVHandle HowFarToNonZero(const SCEV *V, const Loop *L);
/// HowManyLessThans - Return the number of times a backedge containing the
/// specified less-than comparison will execute. If not computable, return
/// UnknownValue. isSigned specifies whether the less-than is signed.
- BackedgeTakenInfo HowManyLessThans(SCEV *LHS, SCEV *RHS, const Loop *L,
- bool isSigned);
+ BackedgeTakenInfo HowManyLessThans(const SCEV *LHS, const SCEV *RHS,
+ const Loop *L, bool isSigned);
/// getPredecessorWithUniqueSuccessorForBB - Return a predecessor of BB
/// (which may not be an immediate predecessor) which has exactly one
@@ -331,7 +344,7 @@
/// getSCEVAtScope - Compute the value of the specified expression within
/// the indicated loop (which may be null to indicate in no loop). If the
/// expression cannot be evaluated, return UnknownValue itself.
- SCEVHandle getSCEVAtScope(SCEV *S, const Loop *L);
+ SCEVHandle getSCEVAtScope(const SCEV *S, const Loop *L);
/// forgetLoopPHIs - Delete the memoized SCEVs associated with the
/// PHI nodes in the given loop. This is used when the trip count of
@@ -457,7 +470,7 @@
/// a conditional between LHS and RHS. This is used to help avoid max
/// expressions in loop trip counts.
bool isLoopGuardedByCond(const Loop *L, ICmpInst::Predicate Pred,
- SCEV *LHS, SCEV *RHS);
+ const SCEV *LHS, const SCEV *RHS);
/// getBackedgeTakenCount - If the specified loop has a predictable
/// backedge-taken count, return it, otherwise return a SCEVCouldNotCompute
@@ -487,11 +500,6 @@
/// is deleted.
void forgetLoopBackedgeTakenCount(const Loop *L);
- /// deleteValueFromRecords - This method should be called by the
- /// client before it removes a Value from the program, to make sure
- /// that no dangling references are left around.
- void deleteValueFromRecords(Value *V);
-
virtual bool runOnFunction(Function &F);
virtual void releaseMemory();
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h?rev=70927&r1=70926&r2=70927&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h Mon May 4 17:30:44 2009
@@ -25,7 +25,6 @@
class Instruction;
class Pass;
class AliasAnalysis;
-class ValueDeletionListener;
/// DeleteDeadBlock - Delete the specified block, which must have no
/// predecessors.
@@ -41,9 +40,8 @@
/// DeleteDeadPHIs - Examine each PHI in the given block and delete it if it
/// is dead. Also recursively delete any operands that become dead as
/// a result. This includes tracing the def-use list from the PHI to see if
-/// it is ultimately unused or if it reaches an unused cycle. If a
-/// ValueDeletionListener is specified, it is notified of the deletions.
-void DeleteDeadPHIs(BasicBlock *BB, ValueDeletionListener *VDL = 0);
+/// it is ultimately unused or if it reaches an unused cycle.
+void DeleteDeadPHIs(BasicBlock *BB);
/// MergeBlockIntoPredecessor - Attempts to merge a block into its predecessor,
/// if possible. The return value indicates success or failure.
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=70927&r1=70926&r2=70927&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Mon May 4 17:30:44 2009
@@ -50,40 +50,17 @@
///
bool isInstructionTriviallyDead(Instruction *I);
-/// ValueDeletionListener - A simple abstract interface for delivering
-/// notifications when Values are deleted.
-///
-/// @todo Consider whether ValueDeletionListener can be made obsolete by
-/// requiring clients to use CallbackVH instead.
-class ValueDeletionListener {
-public:
- /// ValueWillBeDeleted - This method is called shortly before the specified
- /// value will be deleted.
- virtual void ValueWillBeDeleted(Value *V) = 0;
-
-protected:
- virtual ~ValueDeletionListener();
-};
-
/// RecursivelyDeleteTriviallyDeadInstructions - If the specified value is a
/// trivially dead instruction, delete it. If that makes any of its operands
/// trivially dead, delete them too, recursively.
-///
-/// If a ValueDeletionListener is specified, it is notified of instructions that
-/// are actually deleted (before they are actually deleted).
-void RecursivelyDeleteTriviallyDeadInstructions(Value *V,
- ValueDeletionListener *VDL = 0);
+void RecursivelyDeleteTriviallyDeadInstructions(Value *V);
/// RecursivelyDeleteDeadPHINode - If the specified value is an effectively
/// dead PHI node, due to being a def-use chain of single-use nodes that
/// either forms a cycle or is terminated by a trivially dead instruction,
/// delete it. If that makes any of its operands trivially dead, delete them
/// too, recursively.
-///
-/// If a ValueDeletionListener is specified, it is notified of instructions that
-/// are actually deleted (before they are actually deleted).
-void RecursivelyDeleteDeadPHINode(PHINode *PN,
- ValueDeletionListener *VDL = 0);
+void RecursivelyDeleteDeadPHINode(PHINode *PN);
//===----------------------------------------------------------------------===//
// Control Flow Graph Restructuring.
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=70927&r1=70926&r2=70927&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 4 17:30:44 2009
@@ -204,7 +204,7 @@
// SCEVTruncates - Only allow the creation of one SCEVTruncateExpr for any
// particular input. Don't use a SCEVHandle here, or else the object will
// never be deleted!
-static ManagedStatic,
+static ManagedStatic,
SCEVTruncateExpr*> > SCEVTruncates;
SCEVTruncateExpr::SCEVTruncateExpr(const SCEVHandle &op, const Type *ty)
@@ -225,7 +225,7 @@
// SCEVZeroExtends - Only allow the creation of one SCEVZeroExtendExpr for any
// particular input. Don't use a SCEVHandle here, or else the object will never
// be deleted!
-static ManagedStatic,
+static ManagedStatic,
SCEVZeroExtendExpr*> > SCEVZeroExtends;
SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty)
@@ -246,7 +246,7 @@
// SCEVSignExtends - Only allow the creation of one SCEVSignExtendExpr for any
// particular input. Don't use a SCEVHandle here, or else the object will never
// be deleted!
-static ManagedStatic,
+static ManagedStatic,
SCEVSignExtendExpr*> > SCEVSignExtends;
SCEVSignExtendExpr::SCEVSignExtendExpr(const SCEVHandle &op, const Type *ty)
@@ -267,13 +267,12 @@
// SCEVCommExprs - Only allow the creation of one SCEVCommutativeExpr for any
// particular input. Don't use a SCEVHandle here, or else the object will never
// be deleted!
-static ManagedStatic >,
+static ManagedStatic >,
SCEVCommutativeExpr*> > SCEVCommExprs;
SCEVCommutativeExpr::~SCEVCommutativeExpr() {
- SCEVCommExprs->erase(std::make_pair(getSCEVType(),
- std::vector(Operands.begin(),
- Operands.end())));
+ std::vector SCEVOps(Operands.begin(), Operands.end());
+ SCEVCommExprs->erase(std::make_pair(getSCEVType(), SCEVOps));
}
void SCEVCommutativeExpr::print(raw_ostream &OS) const {
@@ -329,7 +328,7 @@
// SCEVUDivs - Only allow the creation of one SCEVUDivExpr for any particular
// input. Don't use a SCEVHandle here, or else the object will never be
// deleted!
-static ManagedStatic,
+static ManagedStatic,
SCEVUDivExpr*> > SCEVUDivs;
SCEVUDivExpr::~SCEVUDivExpr() {
@@ -351,13 +350,13 @@
// SCEVAddRecExprs - Only allow the creation of one SCEVAddRecExpr for any
// particular input. Don't use a SCEVHandle here, or else the object will never
// be deleted!
-static ManagedStatic >,
+static ManagedStatic >,
SCEVAddRecExpr*> > SCEVAddRecExprs;
SCEVAddRecExpr::~SCEVAddRecExpr() {
- SCEVAddRecExprs->erase(std::make_pair(L,
- std::vector(Operands.begin(),
- Operands.end())));
+ std::vector SCEVOps(Operands.begin(), Operands.end());
+ SCEVAddRecExprs->erase(std::make_pair(L, SCEVOps));
}
bool SCEVAddRecExpr::dominates(BasicBlock *BB, DominatorTree *DT) const {
@@ -480,7 +479,7 @@
// be extremely short in practice. Note that we take this approach because we
// do not want to depend on the addresses of the objects we are grouping.
for (unsigned i = 0, e = Ops.size(); i != e-2; ++i) {
- SCEV *S = Ops[i];
+ const SCEV *S = Ops[i];
unsigned Complexity = S->getSCEVType();
// If there are any objects of the same complexity and same value as this
@@ -919,9 +918,9 @@
// something is not already an operand of the multiply. If so, merge it into
// the multiply.
for (; Idx < Ops.size() && isa(Ops[Idx]); ++Idx) {
- SCEVMulExpr *Mul = cast(Ops[Idx]);
+ const SCEVMulExpr *Mul = cast(Ops[Idx]);
for (unsigned MulOp = 0, e = Mul->getNumOperands(); MulOp != e; ++MulOp) {
- SCEV *MulOpSCEV = Mul->getOperand(MulOp);
+ const SCEV *MulOpSCEV = Mul->getOperand(MulOp);
for (unsigned AddOp = 0, e = Ops.size(); AddOp != e; ++AddOp)
if (MulOpSCEV == Ops[AddOp] && !isa(MulOpSCEV)) {
// Fold W + X + (X * Y * Z) --> W + (X * ((Y*Z)+1))
@@ -952,7 +951,7 @@
for (unsigned OtherMulIdx = Idx+1;
OtherMulIdx < Ops.size() && isa(Ops[OtherMulIdx]);
++OtherMulIdx) {
- SCEVMulExpr *OtherMul = cast(Ops[OtherMulIdx]);
+ const SCEVMulExpr *OtherMul = cast(Ops[OtherMulIdx]);
// If MulOp occurs in OtherMul, we can fold the two multiplies
// together.
for (unsigned OMulOp = 0, e = OtherMul->getNumOperands();
@@ -995,7 +994,7 @@
// Scan all of the other operands to this add and add them to the vector if
// they are loop invariant w.r.t. the recurrence.
std::vector LIOps;
- SCEVAddRecExpr *AddRec = cast(Ops[Idx]);
+ const SCEVAddRecExpr *AddRec = cast(Ops[Idx]);
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
if (Ops[i]->isLoopInvariant(AddRec->getLoop())) {
LIOps.push_back(Ops[i]);
@@ -1030,7 +1029,7 @@
for (unsigned OtherIdx = Idx+1;
OtherIdx < Ops.size() && isa(Ops[OtherIdx]);++OtherIdx)
if (OtherIdx != Idx) {
- SCEVAddRecExpr *OtherAddRec = cast(Ops[OtherIdx]);
+ const SCEVAddRecExpr *OtherAddRec = cast(Ops[OtherIdx]);
if (AddRec->getLoop() == OtherAddRec->getLoop()) {
// Other + {A,+,B} + {C,+,D} --> Other + {A+C,+,B+D}
std::vector NewOps(AddRec->op_begin(), AddRec->op_end());
@@ -1059,7 +1058,7 @@
// Okay, it looks like we really DO need an add expr. Check to see if we
// already have one, otherwise create a new one.
- std::vector SCEVOps(Ops.begin(), Ops.end());
+ std::vector SCEVOps(Ops.begin(), Ops.end());
SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scAddExpr,
SCEVOps)];
if (Result == 0) Result = new SCEVAddExpr(Ops);
@@ -1143,7 +1142,7 @@
// Scan all of the other operands to this mul and add them to the vector if
// they are loop invariant w.r.t. the recurrence.
std::vector LIOps;
- SCEVAddRecExpr *AddRec = cast(Ops[Idx]);
+ const SCEVAddRecExpr *AddRec = cast(Ops[Idx]);
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
if (Ops[i]->isLoopInvariant(AddRec->getLoop())) {
LIOps.push_back(Ops[i]);
@@ -1157,7 +1156,7 @@
std::vector NewOps;
NewOps.reserve(AddRec->getNumOperands());
if (LIOps.size() == 1) {
- SCEV *Scale = LIOps[0];
+ const SCEV *Scale = LIOps[0];
for (unsigned i = 0, e = AddRec->getNumOperands(); i != e; ++i)
NewOps.push_back(getMulExpr(Scale, AddRec->getOperand(i)));
} else {
@@ -1188,10 +1187,10 @@
for (unsigned OtherIdx = Idx+1;
OtherIdx < Ops.size() && isa(Ops[OtherIdx]);++OtherIdx)
if (OtherIdx != Idx) {
- SCEVAddRecExpr *OtherAddRec = cast(Ops[OtherIdx]);
+ const SCEVAddRecExpr *OtherAddRec = cast(Ops[OtherIdx]);
if (AddRec->getLoop() == OtherAddRec->getLoop()) {
// F * G --> {A,+,B} * {C,+,D} --> {A*C,+,F*D + G*B + B*D}
- SCEVAddRecExpr *F = AddRec, *G = OtherAddRec;
+ const SCEVAddRecExpr *F = AddRec, *G = OtherAddRec;
SCEVHandle NewStart = getMulExpr(F->getStart(),
G->getStart());
SCEVHandle B = F->getStepRecurrence(*this);
@@ -1216,7 +1215,7 @@
// Okay, it looks like we really DO need an mul expr. Check to see if we
// already have one, otherwise create a new one.
- std::vector SCEVOps(Ops.begin(), Ops.end());
+ std::vector SCEVOps(Ops.begin(), Ops.end());
SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scMulExpr,
SCEVOps)];
if (Result == 0)
@@ -1286,9 +1285,8 @@
}
}
- SCEVAddRecExpr *&Result =
- (*SCEVAddRecExprs)[std::make_pair(L, std::vector(Operands.begin(),
- Operands.end()))];
+ std::vector SCEVOps(Operands.begin(), Operands.end());
+ SCEVAddRecExpr *&Result = (*SCEVAddRecExprs)[std::make_pair(L, SCEVOps)];
if (Result == 0) Result = new SCEVAddRecExpr(Operands, L);
return Result;
}
@@ -1366,7 +1364,7 @@
// Okay, it looks like we really DO need an smax expr. Check to see if we
// already have one, otherwise create a new one.
- std::vector SCEVOps(Ops.begin(), Ops.end());
+ std::vector SCEVOps(Ops.begin(), Ops.end());
SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scSMaxExpr,
SCEVOps)];
if (Result == 0) Result = new SCEVSMaxExpr(Ops);
@@ -1446,7 +1444,7 @@
// Okay, it looks like we really DO need a umax expr. Check to see if we
// already have one, otherwise create a new one.
- std::vector SCEVOps(Ops.begin(), Ops.end());
+ std::vector SCEVOps(Ops.begin(), Ops.end());
SCEVCommutativeExpr *&Result = (*SCEVCommExprs)[std::make_pair(scUMaxExpr,
SCEVOps)];
if (Result == 0) Result = new SCEVUMaxExpr(Ops);
@@ -1467,34 +1465,6 @@
// Basic SCEV Analysis and PHI Idiom Recognition Code
//
-/// deleteValueFromRecords - This method should be called by the
-/// client before it removes an instruction from the program, to make sure
-/// that no dangling references are left around.
-void ScalarEvolution::deleteValueFromRecords(Value *V) {
- SmallVector Worklist;
-
- if (Scalars.erase(V)) {
- if (PHINode *PN = dyn_cast(V))
- ConstantEvolutionLoopExitValue.erase(PN);
- Worklist.push_back(V);
- }
-
- while (!Worklist.empty()) {
- Value *VV = Worklist.back();
- Worklist.pop_back();
-
- for (Instruction::use_iterator UI = VV->use_begin(), UE = VV->use_end();
- UI != UE; ++UI) {
- Instruction *Inst = cast(*UI);
- if (Scalars.erase(Inst)) {
- if (PHINode *PN = dyn_cast(VV))
- ConstantEvolutionLoopExitValue.erase(PN);
- Worklist.push_back(Inst);
- }
- }
- }
-}
-
/// isSCEVable - Test if values of the given type are analyzable within
/// the SCEV framework. This primarily includes integer types, and it
/// can optionally include pointer types if the ScalarEvolution class
@@ -1556,10 +1526,10 @@
SCEVHandle ScalarEvolution::getSCEV(Value *V) {
assert(isSCEVable(V->getType()) && "Value is not SCEVable!");
- std::map::iterator I = Scalars.find(V);
+ std::map::iterator I = Scalars.find(V);
if (I != Scalars.end()) return I->second;
SCEVHandle S = createSCEV(V);
- Scalars.insert(std::make_pair(V, S));
+ Scalars.insert(std::make_pair(SCEVCallbackVH(V, this), S));
return S;
}
@@ -1648,7 +1618,8 @@
void ScalarEvolution::
ReplaceSymbolicValueWithConcrete(Instruction *I, const SCEVHandle &SymName,
const SCEVHandle &NewVal) {
- std::map::iterator SI = Scalars.find(I);
+ std::map::iterator SI =
+ Scalars.find(SCEVCallbackVH(I, this));
if (SI == Scalars.end()) return;
SCEVHandle NV =
@@ -1680,7 +1651,7 @@
SCEVHandle SymbolicName = getUnknown(PN);
assert(Scalars.find(PN) == Scalars.end() &&
"PHI node already processed?");
- Scalars.insert(std::make_pair(PN, SymbolicName));
+ Scalars.insert(std::make_pair(SCEVCallbackVH(PN, this), SymbolicName));
// Using this symbolic name for the PHI, analyze the value coming around
// the back-edge.
@@ -2131,9 +2102,20 @@
/// PHI nodes in the given loop. This is used when the trip count of
/// the loop may have changed.
void ScalarEvolution::forgetLoopPHIs(const Loop *L) {
- for (BasicBlock::iterator I = L->getHeader()->begin();
+ BasicBlock *Header = L->getHeader();
+
+ SmallVector Worklist;
+ for (BasicBlock::iterator I = Header->begin();
PHINode *PN = dyn_cast(I); ++I)
- deleteValueFromRecords(PN);
+ Worklist.push_back(PN);
+
+ while (!Worklist.empty()) {
+ Instruction *I = Worklist.pop_back_val();
+ if (Scalars.erase(I))
+ for (Value::use_iterator UI = I->use_begin(), UE = I->use_end();
+ UI != UE; ++UI)
+ Worklist.push_back(cast(UI));
+ }
}
/// ComputeBackedgeTakenCount - Compute the number of times the backedge
@@ -2384,7 +2366,7 @@
// We can only recognize very limited forms of loop index expressions, in
// particular, only affine AddRec's like {C1,+,C2}.
- SCEVAddRecExpr *IdxExpr = dyn_cast(Idx);
+ const SCEVAddRecExpr *IdxExpr = dyn_cast(Idx);
if (!IdxExpr || !IdxExpr->isAffine() || IdxExpr->isLoopInvariant(L) ||
!isa(IdxExpr->getOperand(0)) ||
!isa(IdxExpr->getOperand(1)))
@@ -2605,7 +2587,7 @@
/// getSCEVAtScope - Compute the value of the specified expression within the
/// indicated loop (which may be null to indicate in no loop). If the
/// expression cannot be evaluated, return UnknownValue.
-SCEVHandle ScalarEvolution::getSCEVAtScope(SCEV *V, const Loop *L) {
+SCEVHandle ScalarEvolution::getSCEVAtScope(const SCEV *V, const Loop *L) {
// FIXME: this should be turned into a virtual method on SCEV!
if (isa(V)) return V;
@@ -2847,13 +2829,13 @@
static std::pair
SolveQuadraticEquation(const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) {
assert(AddRec->getNumOperands() == 3 && "This is not a quadratic chrec!");
- SCEVConstant *LC = dyn_cast(AddRec->getOperand(0));
- SCEVConstant *MC = dyn_cast(AddRec->getOperand(1));
- SCEVConstant *NC = dyn_cast(AddRec->getOperand(2));
+ const SCEVConstant *LC = dyn_cast(AddRec->getOperand(0));
+ const SCEVConstant *MC = dyn_cast(AddRec->getOperand(1));
+ const SCEVConstant *NC = dyn_cast(AddRec->getOperand(2));
// We currently can only solve this if the coefficients are constants.
if (!LC || !MC || !NC) {
- SCEV *CNC = SE.getCouldNotCompute();
+ const SCEV *CNC = SE.getCouldNotCompute();
return std::make_pair(CNC, CNC);
}
@@ -2889,7 +2871,7 @@
APInt NegB(-B);
APInt TwoA( A << 1 );
if (TwoA.isMinValue()) {
- SCEV *CNC = SE.getCouldNotCompute();
+ const SCEV *CNC = SE.getCouldNotCompute();
return std::make_pair(CNC, CNC);
}
@@ -2903,7 +2885,7 @@
/// HowFarToZero - Return the number of times a backedge comparing the specified
/// value to zero will execute. If not computable, return UnknownValue
-SCEVHandle ScalarEvolution::HowFarToZero(SCEV *V, const Loop *L) {
+SCEVHandle ScalarEvolution::HowFarToZero(const SCEV *V, const Loop *L) {
// If the value is a constant
if (const SCEVConstant *C = dyn_cast(V)) {
// If the value is already zero, the branch will execute zero times.
@@ -2911,7 +2893,7 @@
return UnknownValue; // Otherwise it will loop infinitely.
}
- SCEVAddRecExpr *AddRec = dyn_cast(V);
+ const SCEVAddRecExpr *AddRec = dyn_cast(V);
if (!AddRec || AddRec->getLoop() != L)
return UnknownValue;
@@ -2953,8 +2935,8 @@
// the quadratic equation to solve it.
std::pair Roots = SolveQuadraticEquation(AddRec,
*this);
- SCEVConstant *R1 = dyn_cast(Roots.first);
- SCEVConstant *R2 = dyn_cast(Roots.second);
+ const SCEVConstant *R1 = dyn_cast(Roots.first);
+ const SCEVConstant *R2 = dyn_cast(Roots.second);
if (R1) {
#if 0
errs() << "HFTZ: " << *V << " - sol#1: " << *R1
@@ -2983,7 +2965,7 @@
/// HowFarToNonZero - Return the number of times a backedge checking the
/// specified value for nonzero will execute. If not computable, return
/// UnknownValue
-SCEVHandle ScalarEvolution::HowFarToNonZero(SCEV *V, const Loop *L) {
+SCEVHandle ScalarEvolution::HowFarToNonZero(const SCEV *V, const Loop *L) {
// Loops that look like: while (X == 0) are very strange indeed. We don't
// handle them yet except for the trivial case. This could be expanded in the
// future as needed.
@@ -3029,7 +3011,7 @@
/// expressions in loop trip counts.
bool ScalarEvolution::isLoopGuardedByCond(const Loop *L,
ICmpInst::Predicate Pred,
- SCEV *LHS, SCEV *RHS) {
+ const SCEV *LHS, const SCEV *RHS) {
BasicBlock *Preheader = L->getLoopPreheader();
BasicBlock *PreheaderDest = L->getHeader();
@@ -3133,11 +3115,12 @@
/// specified less-than comparison will execute. If not computable, return
/// UnknownValue.
ScalarEvolution::BackedgeTakenInfo ScalarEvolution::
-HowManyLessThans(SCEV *LHS, SCEV *RHS, const Loop *L, bool isSigned) {
+HowManyLessThans(const SCEV *LHS, const SCEV *RHS,
+ const Loop *L, bool isSigned) {
// Only handle: "ADDREC < LoopInvariant".
if (!RHS->isLoopInvariant(L)) return UnknownValue;
- SCEVAddRecExpr *AddRec = dyn_cast(LHS);
+ const SCEVAddRecExpr *AddRec = dyn_cast(LHS);
if (!AddRec || AddRec->getLoop() != L)
return UnknownValue;
@@ -3304,8 +3287,8 @@
// Next, solve the constructed addrec
std::pair Roots =
SolveQuadraticEquation(cast(NewAddRec), SE);
- SCEVConstant *R1 = dyn_cast