[llvm-commits] [llvm] r137680 - /llvm/trunk/utils/TableGen/NeonEmitter.cpp

Bob Wilson bob.wilson at apple.com
Mon Aug 15 16:22:56 PDT 2011


Author: bwilson
Date: Mon Aug 15 18:22:56 2011
New Revision: 137680

URL: http://llvm.org/viewvc/llvm-project?rev=137680&view=rev
Log:
Avoid evaluating Neon macro arguments more than once by disabling type checks.
It turns out that the use of "__extension__" in these macros was disabling
the expected "incompatible pointer" warnings, so these type checks were not
doing anything anyway.  They introduced a serious bug by evaluating some
macro arguments twice, which is a big problem for arguments with side effects.
I'll have to find another way to get the right type checking.  Radar 9947657.

Modified:
    llvm/trunk/utils/TableGen/NeonEmitter.cpp

Modified: llvm/trunk/utils/TableGen/NeonEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=137680&r1=137679&r2=137680&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/NeonEmitter.cpp Mon Aug 15 18:22:56 2011
@@ -485,6 +485,7 @@
 /// defined as a macro should be accessed directly instead of being first
 /// assigned to a local temporary.
 static bool MacroArgUsedDirectly(const std::string &proto, unsigned i) {
+  // True for constant ints (i), pointers (p) and const pointers (c).
   return (proto[i] == 'i' || proto[i] == 'p' || proto[i] == 'c');
 }
 
@@ -525,24 +526,16 @@
   for (unsigned i = 1, e = proto.size(); i != e; ++i, ++arg) {
     // Do not create a temporary for an immediate argument.
     // That would defeat the whole point of using a macro!
-    if (proto[i] == 'i')
+    // FIXME: For other (non-immediate) arguments that are used directly, a
+    // local temporary (or some other method) is still needed to get the
+    // correct type checking, even if that temporary is not used for anything.
+    // This is omitted for now because it turns out the the use of
+    // "__extension__" in the macro disables any warnings from the pointer
+    // assignment.
+    if (MacroArgUsedDirectly(proto, i))
       continue;
     generatedLocal = true;
 
-    // For other (non-immediate) arguments that are used directly, a local
-    // temporary is still needed to get the correct type checking, even though
-    // that temporary is not used for anything.
-    if (MacroArgUsedDirectly(proto, i)) {
-      s += TypeString(proto[i], typestr) + " __";
-      s.push_back(arg);
-      s += "_ = (__";
-      s.push_back(arg);
-      s += "); (void)__";
-      s.push_back(arg);
-      s += "_; ";
-      continue;
-    }
-
     s += TypeString(proto[i], typestr) + " __";
     s.push_back(arg);
     s += " = (";





More information about the llvm-commits mailing list