<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">There might be an issue with this related to -fpermissive. Doing some fixing.<br><div><br></div><div><div><div>On Jul 5, 2013, at 6:39 PM, Michael Gottesman <<a href="mailto:mgottesman@apple.com">mgottesman@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Author: mgottesman<br>Date: Fri Jul  5 20:39:18 2013<br>New Revision: 185740<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=185740&view=rev">http://llvm.org/viewvc/llvm-project?rev=185740&view=rev</a><br>Log:<br>[objc-arc] Refactor runtime entrypoint declaration entrypoint creation.<br><br>This is the first patch in a series of 3 patches which clean up how we create<br>runtime function declarations in the ARC optimizer when they do not exist<br>already in the IR.<br><br>Currently we have a bunch of duplicated code in ObjCARCOpts, ObjCARCContract<br>that does this. This patch refactors that code into a separate class called<br>ARCRuntimeEntryPoints which lazily creates the declarations for said<br>entrypoints.<br><br>The next two patches will consist of the work of refactoring<br>ObjCARCContract/ObjCARCOpts to use this new code.<br><br>Added:<br>   llvm/trunk/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h<br><br>Added: llvm/trunk/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h<br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h?rev=185740&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h?rev=185740&view=auto</a><br>==============================================================================<br>--- llvm/trunk/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h (added)<br>+++ llvm/trunk/lib/Transforms/ObjCARC/ARCRuntimeEntryPoints.h Fri Jul  5 20:39:18 2013<br>@@ -0,0 +1,178 @@<br>+//===- ARCRuntimeEntryPoints.h - ObjC ARC Optimization --*- mode: c++ -*---===//<br>+//<br>+//                     The LLVM Compiler Infrastructure<br>+//<br>+// This file is distributed under the University of Illinois Open Source<br>+// License. See LICENSE.TXT for details.<br>+//<br>+//===----------------------------------------------------------------------===//<br>+/// \file<br>+/// This file contains a class ARCRuntimeEntryPoints for use in<br>+/// creating/managing references to entry points to the arc objective c runtime.<br>+///<br>+/// WARNING: This file knows about certain library functions. It recognizes them<br>+/// by name, and hardwires knowledge of their semantics.<br>+///<br>+/// WARNING: This file knows about how certain Objective-C library functions are<br>+/// used. Naive LLVM IR transformations which would otherwise be<br>+/// behavior-preserving may break these assumptions.<br>+///<br>+//===----------------------------------------------------------------------===//<br>+<br>+#ifndef LLVM_TRANSFORMS_SCALAR_ARCRUNTIMEENTRYPOINTS_H<br>+#define LLVM_TRANSFORMS_SCALAR_ARCRUNTIMEENTRYPOINTS_H<br>+<br>+#include "ObjCARC.h"<br>+<br>+namespace llvm {<br>+namespace objcarc {<br>+<br>+/// Declarations for ObjC runtime functions and constants. These are initialized<br>+/// lazily to avoid cluttering up the Module with unused declarations.<br>+class ARCRuntimeEntryPoints {<br>+public:<br>+  enum EntryPointType {<br>+    EPT_AutoreleaseRV,<br>+    EPT_Release,<br>+    EPT_Retain,<br>+    EPT_RetainBlock,<br>+    EPT_Autorelease,<br>+    EPT_StoreStrong,<br>+    EPT_RetainRV,<br>+    EPT_RetainAutorelease,<br>+    EPT_RetainAutoreleaseRV<br>+  };<br>+<br>+  ARCRuntimeEntryPoints() : Module(0),<br>+                            AutoreleaseRV(0),<br>+                            Release(0),<br>+                            Retain(0),<br>+                            RetainBlock(0),<br>+                            Autorelease(0),<br>+                            StoreStrong(0),<br>+                            RetainRV(0),<br>+                            RetainAutorelease(0),<br>+                            RetainAutoreleaseRV(0) { }<br>+<br>+  ~ARCRuntimeEntryPoints() { }<br>+<br>+  void Initialize(Module *M) {<br>+    Module = M;<br>+  }<br>+<br>+  Constant *get(const EntryPointType entry) {<br>+    assert(Module != 0 && "Not initialized.");<br>+<br>+    switch (entry) {<br>+    case EPT_AutoreleaseRV:<br>+      return getI8XRetI8XEntryPoint(AutoreleaseRV,<br>+                                    "objc_autoreleaseReturnValue", true);<br>+    case EPT_Release:<br>+      return getVoidRetI8XEntryPoint(Release, "objc_release");<br>+    case EPT_Retain:<br>+      return getI8XRetI8XEntryPoint(Retain, "objc_retain", true);<br>+    case EPT_RetainBlock:<br>+      return getI8XRetI8XEntryPoint(RetainBlock, "objc_retainBlock", false);<br>+    case EPT_Autorelease:<br>+      return getI8XRetI8XEntryPoint(Autorelease, "objc_autorelease", true);<br>+    case EPT_StoreStrong:<br>+      return getI8XRetI8XXI8XEntryPoint(StoreStrong, "objc_storeStrong");<br>+    case EPT_RetainAutorelease:<br>+      return getI8XRetI8XEntryPoint(RetainAutorelease, "objc_retainAutorelease",<br>+                                    true);<br>+    case EPT_RetainAutoreleaseRV:<br>+      return getI8XRetI8XEntryPoint(RetainAutoreleaseRV,<br>+                                    "objc_retainAutoreleaseReturnValue", true);<br>+    case EPT_RetainRV:<br>+      return getI8XRetI8XEntryPoint(RetainRV,<br>+                                    "objc_retainAutoreleasedReturnValue", true);<br>+    }<br>+  }<br>+<br>+private:<br>+  /// Cached reference to the module which we will insert declarations into.<br>+  Module *Module;<br>+<br>+  /// Declaration for ObjC runtime function objc_autoreleaseReturnValue.<br>+  Constant *AutoreleaseRV;<br>+  /// Declaration for ObjC runtime function objc_release.<br>+  Constant *Release;<br>+  /// Declaration for ObjC runtime function objc_retain.<br>+  Constant *Retain;<br>+  /// Declaration for ObjC runtime function objc_retainBlock.<br>+  Constant *RetainBlock;<br>+  /// Declaration for ObjC runtime function objc_autorelease.<br>+  Constant *Autorelease;<br>+  /// Declaration for objc_storeStrong().<br>+  Constant *StoreStrong;<br>+  /// Declaration for objc_retainAutoreleasedReturnValue().<br>+  Constant *RetainRV;<br>+  /// Declaration for objc_retainAutorelease().<br>+  Constant *RetainAutorelease;<br>+  /// Declaration for objc_retainAutoreleaseReturnValue().<br>+  Constant *RetainAutoreleaseRV;<br>+<br>+  Constant *getVoidRetI8XEntryPoint(Constant *&Decl,<br>+                                    const char *Name) {<br>+    if (Decl)<br>+      return Decl;<br>+<br>+    LLVMContext &C = Module->getContext();<br>+    Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };<br>+    AttributeSet Attr =<br>+      AttributeSet().addAttribute(Module->getContext(),<br>+                                  AttributeSet::FunctionIndex,<br>+                                  Attribute::NoUnwind);<br>+    FunctionType *Fty = FunctionType::get(Type::getVoidTy(C), Params,<br>+                                          /*isVarArg=*/false);<br>+    return Decl = Module->getOrInsertFunction(Name, Fty, Attr);<br>+  }<br>+<br>+  Constant *getI8XRetI8XEntryPoint(Constant *& Decl,<br>+                                   const char *Name,<br>+                                   bool NoUnwind = false) {<br>+    if (Decl)<br>+      return Decl;<br>+<br>+    LLVMContext &C = Module->getContext();<br>+    Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));<br>+    Type *Params[] = { I8X };<br>+    FunctionType *Fty = FunctionType::get(I8X, Params, /*isVarArg=*/false);<br>+    AttributeSet Attr = AttributeSet();<br>+<br>+    if (NoUnwind)<br>+      Attr = Attr.addAttribute(Module->getContext(),<br>+                               AttributeSet::FunctionIndex,<br>+                               Attribute::NoUnwind);<br>+<br>+    return Decl = Module->getOrInsertFunction(Name, Fty, Attr);<br>+  }<br>+<br>+  Constant *getI8XRetI8XXI8XEntryPoint(Constant *&Decl,<br>+                                       const char *Name) {<br>+    if (Decl)<br>+      return Decl;<br>+<br>+    LLVMContext &C = Module->getContext();<br>+    Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));<br>+    Type *I8XX = PointerType::getUnqual(I8X);<br>+    Type *Params[] = { I8XX, I8X };<br>+<br>+    AttributeSet Attr =<br>+      AttributeSet().addAttribute(Module->getContext(),<br>+                                  AttributeSet::FunctionIndex,<br>+                                  Attribute::NoUnwind);<br>+    Attr = Attr.addAttribute(Module->getContext(), 1, Attribute::NoCapture);<br>+<br>+    FunctionType *Fty = FunctionType::get(Type::getVoidTy(C), Params,<br>+                                          /*isVarArg=*/false);<br>+<br>+    return Decl = Module->getOrInsertFunction(Name, Fty, Attr);<br>+  }<br>+<br>+}; // class ARCRuntimeEntryPoints<br>+<br>+} // namespace objcarc<br>+} // namespace llvm<br>+<br>+#endif // LLVM_TRANSFORMS_SCALAR_ARCRUNTIMEENTRYPOINTS_H<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div></body></html>