pocl/pocl — pull request #93 by MaxBarraclough (2014-07-03 16:54:03+00:00)
Title: Fix compilation against LLVM 3.4

On Mint Linux x86_64, compilation was failing. (LLVM 3.4, and Clang 3.4, were used.)

This commit fixes the build. Regarding whether things actually work: most the regressions tests seem to succeed, but:

test_structs_as_args produces:
```c++
ERROR: clEnqueueNDRangeKernel(-52)
```

test_constant_array produces:
```c++
/tmp/poclnrWIKE/program.cl:7:10: error: passing 'char *' to parameter of type '__constant char *' changes address space of pointer
printf("sum=%g\n", s);
^~~~~~~~~~
/usr/local/share/pocl/include/_kernel.h:2123:40: note: passing argument to parameter 'format' here
int _cl_printf(constant char* restrict format, ...);
^
1 error generated.
ERROR: clBuildProgram(-11)
```

test_infinite_loop produces:
```c++
/tmp/poclAjAOiO/program.cl:7:10: error: passing 'char *' to parameter of type '__constant char *' changes address space of pointer
printf("sum=%g\n", s);
^~~~~~~~~~
/usr/local/share/pocl/include/_kernel.h:2123:40: note: passing argument to parameter 'format' here
int _cl_printf(constant char* restrict format, ...);
^
1 error generated.
ERROR: clBuildProgram(-11)
```

Still more tests fail outside the regression-tests collection.

Without my changes to TargetAddressSpaces.cc, I see the following (from g++ version 4.8.1):

```c++
TargetAddressSpaces.cc: In member function 'virtual bool pocl::TargetAddressSpaces::runOnModule(llvm::Module&)':
TargetAddressSpaces.cc:202:17: error: 'AddrSpaceCastInst' was not declared in this scope
if (isa(instr)) {
^
TargetAddressSpaces.cc:202:41: error: no matching function for call to 'isa(llvm::Instruction*&)'
if (isa(instr)) {
^
TargetAddressSpaces.cc:202:41: note: candidate is:
In file included from /usr/lib/llvm-3.4/include/llvm/IR/Type.h:19:0,
from /usr/lib/llvm-3.4/include/llvm/IR/DerivedTypes.h:21,
from /usr/lib/llvm-3.4/include/llvm/IR/Instructions.h:23,
from TargetAddressSpaces.cc:31:
/usr/lib/llvm-3.4/include/llvm/Support/Casting.h:134:13: note: template bool llvm::isa(const Y&)
inline bool isa(const Y &Val) {
^
/usr/lib/llvm-3.4/include/llvm/Support/Casting.h:134:13: note: template argument deduction/substitution failed:
TargetAddressSpaces.cc:202:41: error: template argument 1 is invalid
if (isa(instr)) {
^
```