llvm

Trouble disabling LLVM optimizations via pragma

两盒软妹~` 提交于 2019-11-29 06:55:32
I have a chunk of code that crashes unless I build with optimizations off. I'm building with LLVM compiler 2.0 I would like to turn off optimizations by wrapping the offending code with a #pragma compiler directive; or turn off optimizations for an entire file. I've been digging in the clang manual and code; but nothing jumps out at me. Does anyone know how to change the optimizations for a single CU (as opposed to for the entire app)? Brad Larson You can set per-file compiler flags in Xcode. In Xcode 4 (which I assume you're using because of the LLVM 2.0 reference), first select the project

What is GCC_NO_COMMON_BLOCKS used for?

a 夏天 提交于 2019-11-29 05:27:41
I found that my project sets GCC_NO_COMMON_BLOCKS = NO under Apple LLVM Compiler 3.1 - Code Generation settings, as "No Common Blocks" I would like to know: what is that flag used for? Thanks a lot JustSid From Xcode's quick help: In C, allocate even uninitialized global variables in the data section of the object file, rather than generating them as common blocks. This has the effect that if the same variable is declared (without extern ) in two different compilations, you will get an error when you link them. The only reason this might be useful is if you wish to verify that the program will

iOSApp 二进制文件重排

家住魔仙堡 提交于 2019-11-29 04:39:46
其实二进制文件重排很简单啊,重点在于生成 order 文件。我基于 Clang SanitizerCoverage 和业界已有的经验,整了个 AppOrderFiles ,一个调用搞定!Enjoy it! 1 2 3 AppOrderFiles(^(NSString *orderFilePath) { NSLog(@"OrderFilePath:%@", orderFilePath); }); 苹果官方文档的古老方案 苹果的官方文档很早就给了二进制文件重排的方案: Improving Locality of Reference ,『早』到甚至被苹果提示这份文档已经年久失修,部分工具和链接失效了。文档的过时不仅体现在还是 GCC 时代,连工具链比如像 gprof 也不能用了,不过 Google 也给出了 macOS 上的替代品,有兴趣的可以去研究下。 Facebook 的 hfsort 需要先用 hf-prod-collect.sh 收集数据,然后塞给 hfsort 生成 hotfuncs.txt 文件。很好很强大,不过对于编程小白来说有一定的使用成本。 PS:此方案来自于我写了这篇文章后,jmpews 大神丢给我了个链接,受益匪浅。(其实我啥都看不懂) 基于 Clang SanitizerCoverage 的方案 在 Clang 10 documentation 中可以看到

warning: duplicate protocol definition of '…' is ignored

陌路散爱 提交于 2019-11-29 04:37:53
How should I respond to this warning? warning: duplicate protocol definition of '...' is ignored My protocol declaration is in its own .h file, and it is #import'ed in a few other files in my project. Well, just in case, here's the entire header file with the protocol declaration: #import <Foundation/Foundation.h> @class Wrapper; @protocol WrapperDelegate @required - (void)wrapper:(Wrapper *)wrapper didRetrieveData:(NSData *)data; @optional - (void)wrapperHasBadCredentials:(Wrapper *)wrapper; - (void)wrapper:(Wrapper *)wrapper didCreateResourceAtURL:(NSString *)url; - (void)wrapper:(Wrapper *

Is self.iVar necessary for strong properties with ARC?

喜你入骨 提交于 2019-11-29 03:17:47
If I declare a property strong, like so: @property (strong, nonatomic) UIView *iVar; When I'm setting it, does it matter if I do iVar = ... or self.iVar = ... ? It seems that with ARC, they do the same thing. If I only declare the instance variable (not the @property), e.g., BOOL selected , does that mean it's inferred to be __unsafe_unretained (since there's no property specifying it to be strong), or must I explicitly specify that? It seems like I may have answered my own questions above in answering ARC: How to release static variable? , but I'm still slightly confused on the above

Using #pragma to suppress “Instance method not found” warnings in Xcode

落爺英雄遲暮 提交于 2019-11-29 02:26:28
I want to use #pragma (in Xcode) to suppress the warning: warning: instance method '-someMethod' not found (return type defaults to 'id') I've tried: #pragma GCC diagnostic ignored "-Wmissing-declarations" And several others, but nothing works. What warning causes the "instance method not found"? Edit As requested here is the actual code: ... if (sampleRate > 0 && ![self isFinishing]) //<--- Warning here { return self.progress; } ... And the build log output: /Users/User1/Documents/Project/branch/client/Folder/CodeFile.m:26:32:{26:32-26:50}: warning: instance method '-isFinishing' not found

How to embed LLVM assembly or intrinsics in C program with Clang?

不羁岁月 提交于 2019-11-29 01:50:23
C compilers allows to embed assembly code in a C program. I am pretty sure that Clang should allow embedding LLVM assembly or intrinsic code in C program. How can I embed LLVM assembly in C code? Oak Right now you can't. You can, however, write an LLVM assembly function separately in its own file, mark it as alwaysinline , then compile it with the rest of your files - this should get you the same result. See this related question on how to first compile your C files to IR and then link them together . You can even compile the files separately and make sure you perform link-time optimization

Installing LLVM libraries along with Xcode

廉价感情. 提交于 2019-11-29 00:53:24
问题 So I just installed Xcode on my Mac and now I would like to install LLVM as well in order to play around a bit with LLVM itself. Currently the compiler can (obviously) not find the required header files. So what is the best way to install LLVM if you already have clang, packed with Xcode, on your system? Thanks in advance. 回答1: If you do not need to read LLVM implementation source code(such as in lib / tools directories) and might only play with libclang , perhaps using homebrew is enough for

Out-of-Line Virtual Method

Deadly 提交于 2019-11-29 00:21:42
问题 What exactly is a out-of-line virtual method and why does it affect link times? http://llvm.org/docs/CodingStandards.html says If a class is defined in a header file and has a vtable (either it has virtual methods or it derives from classes with virtual methods), it must always have at least one out-of-line virtual method in the class. Without this, the compiler will copy the vtable and RTTI into every .o file that #includes the header, bloating .o file sizes and increasing link times. 回答1:

If a subclass refers to a superclass ivar, synthesizing an unrelated property fails

只愿长相守 提交于 2019-11-28 23:14:45
Edit: I just noticed this other Stack Overflow question asking much the same thing: Why does a subclass @property with no corresponding ivar hide superclass ivars? This is some interesting behavior that I cannot find documented in anything official or unofficial (blog, tweet, SO question, etc). I have boiled it down to its essence and tested this in a fresh Xcode project, but I can't explain it. MyBaseClass has an instance variable: @interface MyBaseClass : NSObject { NSObject *fooInstanceVar; } @end MySubclass extends MyBaseClass, and declares a totally unrelated property (that is, the