llvm

LLVM and GCC, different output same code

混江龙づ霸主 提交于 2019-12-11 01:54:55
问题 This is a sample code just to show a different output from the LLVM compiler and the GCC. I wonder why? The answer should be very simple, but I can't see it. (Xcode 4.6.1) The code: #include <stdio.h> #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) int increment() { static int i = 42; i += 5; printf("increment returns %d\n",i); return i; } int main( int argc, char ** argv ) { int x = 50; printf("max of %d and %d is %d\n", x,increment(),MAX(x, increment())); printf("max of %d and %d is %d\n", x

Fatal Error building the llvm source code in Ubuntu

寵の児 提交于 2019-12-11 01:31:38
问题 I am trying to build LLVM source code on Ubuntu 16.04. I have tried versions 4.0.1, 4.0.0 and 3.9.0 with sources from here. I have also tried using the source from svn as shown in several tutorials. Here is the error I get : [1480/1747] Linking CXX executable bin/clang-3.9 FAILED: : && /usr/bin/c++ -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual

Getting undefined symbol: __asan_memset when trying to use Clang address sanitizer

倖福魔咒の 提交于 2019-12-11 01:17:45
问题 I'm trying to use address sanitizer with clang to compile a C++ application but getting the following error: /Class.so: undefined symbol: __asan_memset I have added -fsanitize=address to the compiler flags /opt/llvm-3.8.0/bin/clang++ -M --gcc-toolchain=/opt/gcc-5.2.0 -fsanitize=address and I have added -fsanitize=address and -lasan to the linker flags: -fsanitize=address -lasan -shared -fuse-ld=gold-2.25 -o Class.so Class.o What else do I need to do to get this to work? 回答1: You main

Pass compound compiler options using cmake

谁都会走 提交于 2019-12-11 01:00:35
问题 I am trying to pass "compound" options to the compiler using cmake's add_compile_options . That is, options involving two (or more) flags that must be passed in a particular order and where none of the flags can be ommitted even if they have already be passed to the compiler. An example would be all the llvm options that must be passed through clang to llvm, e.g., -mllvm -ABC -mllvm -XYZ -mllvm ... . I would prefer not to use CMake's antipattern set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mllvm

CLANG optimizing using SVML and it's autovectorization

左心房为你撑大大i 提交于 2019-12-11 00:58:14
问题 Consider simple function: #include <math.h> void ahoj(float *a) { for (int i=0; i<256; i++) a[i] = sin(a[i]); } Try that at https://godbolt.org/z/ynQKRb, and use following settings -fveclib=SVML -mfpmath=sse -ffast-math -fno-math-errno -O3 -mavx2 -fvectorize Select x86_64 CLANG 7.0, currently the newest. This is the most interesting part of the result: vmovups ymm0, ymmword ptr [rdi] vmovups ymm1, ymmword ptr [rdi + 32] vmovups ymmword ptr [rsp], ymm1 # 32-byte Spill vmovups ymm1, ymmword ptr

Adding support for a memory type similar to __shared__ in CUDA using clang-llvm compiler

◇◆丶佛笑我妖孽 提交于 2019-12-11 00:27:33
问题 I am working towards adding a new memory type similar to __shared__ in CUDA called __noc__ which needs to be compiled using clang-llvm. Following are the steps followed to achieve the parsing for the new memory type taking reference from the answer: Step 1 : In the clangs's Attr.td file (clang/include/clang/Basic/Attr.td), the noc keyword was added similar to shared keyword. def CUDAShared : InheritableAttr { let Spellings = [GNU<"shared">]; let Subjects = SubjectList<[Var]>; let LangOpts =

ocaml llvm kaleidoscope tutorial “Unbound module LlvmExecutionEngine”

大兔子大兔子 提交于 2019-12-10 23:59:40
问题 I switched to my mac and no longer have this issue but have a similar one. OCaml llvm "Unbound module ExecutionEngine" I'm trying to get this to work: https://github.com/llvm-mirror/llvm/tree/master/examples/OCaml-Kaleidoscope/Chapter7 from this tutorial http://llvm.org/docs/tutorial/OCamlLangImpl7.html (I'm 99% sure these two are by the same people) After getting around a few issues I have reached a stumbling block for the last few hours of me@mypc:~/Desktop/llvm-master/examples/OCaml

Clang, Microsoft linker and standard library

老子叫甜甜 提交于 2019-12-10 21:35:37
问题 I have successfully built Clang with Microsoft C++ and I'm trying to get it to compile a hello world test case; it gets as far as generating an object file, linking with the standard library being the remaining stumbling block: hello-202520.o : error LNK2019: unresolved external symbol _printf referenced in function _main LINK : error LNK2001: unresolved external symbol _mainCRTStartup There are comments from previous years saying Clang doesn't yet do Windows linking at all, but I get the

Fedora 21 with clang, without gcc

你。 提交于 2019-12-10 20:45:21
问题 Can you (reasonably) get Fedora 21 to where it only has llvm/clang/libc++/libc++abi? (I found some things suggesting no, but they were all about 3 years old, and llvm/clang has come a long way since then.) With a fresh install, I tried yum install gcc gcc-c++ (downloaded, built, installed llvm/cfe(clang)/compiler-rt/libcxx/libcxxabi from svn) yum remove gcc gcc-c++ added to /etc/profile: export CC=/usr/local/bin/clang \ export CXX=/usr/local/bin/clang++ (in case of hard wiring) ln -s /usr

'main' function not found in module when using llvm bindings with Haskell

拜拜、爱过 提交于 2019-12-10 19:20:39
问题 I'm trying to use Haskell's LLVM bindings to create a very simple 'hello world' standalone app. The idea is, when I run my Haskell application, it will spit out some bytecode that can in turn be run and will output "hello world!" -- hellofunc prints out "hello world" hellofunc :: CodeGenModule (Function (IO ())) _main :: (Function (IO ())) -> CodeGenModule (Function (IO ())) _main func = createNamedFunction ExternalLinkage "main" $ do call func ret () main = writeCodeGenModule "hello.bc"