[llvm-commits] [dragonegg] r141280 - /dragonegg/trunk/src/Types.cpp
Duncan Sands
baldrick at free.fr
Thu Oct 6 02:21:50 PDT 2011
Author: baldrick
Date: Thu Oct 6 04:21:48 2011
New Revision: 141280
URL: http://llvm.org/viewvc/llvm-project?rev=141280&view=rev
Log:
Hook up the returns_twice attribute to GCC's ECF_RETURNS_TWICE.
While there, rearrange existing code and comments a bit.
Modified:
dragonegg/trunk/src/Types.cpp
Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=141280&r1=141279&r2=141280&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Thu Oct 6 04:21:48 2011
@@ -737,6 +737,14 @@
int flags = flags_from_decl_or_type(decl ? decl : type);
+ // Check for 'readnone' and 'readonly' function attributes.
+ if (flags & ECF_CONST)
+ FnAttributes |= Attribute::ReadNone;
+ else if (flags & ECF_PURE)
+ FnAttributes |= Attribute::ReadOnly;
+
+ // TODO: Handle ECF_LOOPING_CONST_OR_PURE
+
// Check for 'noreturn' function attribute.
if (flags & ECF_NORETURN)
FnAttributes |= Attribute::NoReturn;
@@ -745,20 +753,9 @@
if (flags & ECF_NOTHROW)
FnAttributes |= Attribute::NoUnwind;
- // Check for 'readnone' function attribute.
- // Both PURE and CONST will be set if the user applied
- // __attribute__((const)) to a function the compiler
- // knows to be pure, such as log. A user or (more
- // likely) libm implementor might know their local log
- // is in fact const, so this should be valid (and gcc
- // accepts it). But llvm IR does not allow both, so
- // set only ReadNone.
- if (flags & ECF_CONST)
- FnAttributes |= Attribute::ReadNone;
-
- // Check for 'readonly' function attribute.
- if (flags & ECF_PURE && !(flags & ECF_CONST))
- FnAttributes |= Attribute::ReadOnly;
+ // Check for 'returnstwice' function attribute.
+ if (flags & ECF_RETURNS_TWICE)
+ FnAttributes |= Attribute::ReturnsTwice;
// Since they write the return value through a pointer,
// 'sret' functions cannot be 'readnone' or 'readonly'.
More information about the llvm-commits
mailing list