View | Details | Raw Unified | Return to bug 182497 | Differences between
and this patch

Collapse All | Expand All

(-)./Makefile (-10 / +13 lines)
Lines 3-8 Link Here
3
3
4
PORTNAME=	clay
4
PORTNAME=	clay
5
PORTVERSION=	0.1.2
5
PORTVERSION=	0.1.2
6
PORTREVISION=	1
6
CATEGORIES=	lang
7
CATEGORIES=	lang
7
MASTER_SITES=	https://github.com/jckarter/${PORTNAME}/tarball/v${PORTVERSION}/
8
MASTER_SITES=	https://github.com/jckarter/${PORTNAME}/tarball/v${PORTVERSION}/
8
DISTNAME=	jckarter-${PORTNAME}-v${PORTVERSION}-0-g${GITVERSION}
9
DISTNAME=	jckarter-${PORTNAME}-v${PORTVERSION}-0-g${GITVERSION}
Lines 10-24 Link Here
10
MAINTAINER=	jyyou@cs.nctu.edu.tw
11
MAINTAINER=	jyyou@cs.nctu.edu.tw
11
COMMENT=	A language designed for generic programming
12
COMMENT=	A language designed for generic programming
12
13
13
LICENSE=	BSD
14
LICENSE=	BSD2CLAUSE
14
15
15
BUILD_DEPENDS=	llvm31>=3.1:${PORTSDIR}/devel/llvm31
16
BUILD_DEPENDS=	llvm-config32:${PORTSDIR}/devel/llvm32
17
RUN_DEPENDS=	clang32:${PORTSDIR}/lang/clang32
16
18
17
OPTIONS_DEFINE=		BINDGEN
19
OPTIONS_DEFINE=		BINDGEN
18
BINDGEN_DESC=		Build with binding generator
20
BINDGEN_DESC=		Build with binding generator
19
OPTIONS_DEFAULT=	BINDGEN
21
OPTIONS_DEFAULT=	BINDGEN
20
22
21
GITVERSION=	751ebe3
23
GITVERSION=	751ebe3
24
PATCH_STRIP=	-p1
22
WRKSRC=		${WRKDIR}/jckarter-${PORTNAME}-${GITVERSION}
25
WRKSRC=		${WRKDIR}/jckarter-${PORTNAME}-${GITVERSION}
23
26
24
ONLY_FOR_ARCHS=	i386 amd64
27
ONLY_FOR_ARCHS=	i386 amd64
Lines 26-50 Link Here
26
USES=		cmake
29
USES=		cmake
27
CMAKE_ARGS+=	-G "Unix Makefiles" -DBUILD_FIX=false
30
CMAKE_ARGS+=	-G "Unix Makefiles" -DBUILD_FIX=false
28
31
29
CC=		clang
32
CC=		clang32
30
CXX=		clang++
33
CXX=		clang++32
31
34
32
NO_STAGE=	yes
35
NO_STAGE=	yes
33
.include <bsd.port.pre.mk>
36
.include <bsd.port.pre.mk>
34
37
38
.if ${OSVERSION} >= 1000000
39
BROKEN=		Does not work on 10.0 and above
40
.endif
41
35
.if ${PORT_OPTIONS:MBINDGEN}
42
.if ${PORT_OPTIONS:MBINDGEN}
36
PLIST_SUB+=	BINDGEN=""
43
PLIST_SUB+=	BINDGEN=""
44
BUILD_DEPENDS+=	clang32:${PORTSDIR}/lang/clang32
37
.else
45
.else
38
PLIST_SUB+=	BINDGEN="@comment "
46
PLIST_SUB+=	BINDGEN="@comment "
39
CMAKE_ARGS+=	-DBUILD_BINDGEN=false
47
CMAKE_ARGS+=	-DBUILD_BINDGEN=false
40
.endif
48
.endif
41
49
42
.if ${OSVERSION} < 900044 || ${PORT_OPTIONS:MBINDGEN}
50
.if ! ${PORT_OPTIONS:MDOCS}
43
BUILD_DEPENDS+=	clang31>=3.1:${PORTSDIR}/lang/clang31
44
RUN_DEPENDS+=	clang31>=3.1:${PORTSDIR}/lang/clang31
45
.endif
46
47
.if defined(NOPORTDOCS)
48
pre-configure:
51
pre-configure:
49
	${REINPLACE_CMD} \
52
	${REINPLACE_CMD} \
50
	    -e 's|install(DIRECTORY doc/ DESTINATION share/doc/clay)||' \
53
	    -e 's|install(DIRECTORY doc/ DESTINATION share/doc/clay)||' \
(-)./files/patch-llvm32 (+508 lines)
Line 0 Link Here
1
diff --git a/CMakeLists.txt b/CMakeLists.txt
2
index 89930e5..99ef0cc 100644
3
--- a/CMakeLists.txt
4
+++ b/CMakeLists.txt
5
@@ -15,16 +15,16 @@
6
 if(UNIX)
7
     set(LLVM_DIR "/usr/local" CACHE PATH "llvm install path")
8
 
9
-    find_program(LLVM_CONFIG llvm-config ${LLVM_DIR}/bin
10
-        DOC "path to llvm-config")
11
+    find_program(LLVM_CONFIG llvm-config32 ${LLVM_DIR}/bin
12
+        DOC "path to llvm-config32")
13
 
14
     execute_process(
15
         COMMAND ${LLVM_CONFIG} --version
16
         OUTPUT_VARIABLE LLVM_VERSION
17
         OUTPUT_STRIP_TRAILING_WHITESPACE
18
     )
19
-    if(NOT ${LLVM_VERSION} STREQUAL "3.1")
20
-        message(FATAL_ERROR "Clay requires LLVM 3.1.")
21
+    if(NOT ${LLVM_VERSION} STREQUAL "3.2")
22
+        message(FATAL_ERROR "Clay requires LLVM 3.2.")
23
     endif()
24
 
25
     execute_process(
26
diff --git a/README.txt b/README.txt
27
index 855a4ab..7999b24 100644
28
--- a/README.txt
29
+++ b/README.txt
30
@@ -9,7 +9,7 @@ Visit http://claylabs.com/clay for more information.
31
 Pre-requisites
32
 --------------
33
 
34
-Clay requires LLVM 3.1, Clang 3.1, and CMake version 2.6 or later.
35
+Clay requires LLVM 3.2, Clang 3.2, and CMake version 2.6 or later.
36
 
37
 CMake Configuration
38
 -------------------
39
@@ -20,7 +20,7 @@ be customized by passing cmake arguments of the form
40
 CMake variables such as CMAKE_INSTALL_PREFIX and CMAKE_BUILD_TYPE, Clay's
41
 build system uses the following variables:
42
 
43
-* LLVM_DIR can be set to the install prefix of an LLVM 3.1 installation.
44
+* LLVM_DIR can be set to the install prefix of an LLVM 3.2 installation.
45
   If not set, CMake will look for an 'llvm-config' script on the PATH.
46
 * PYTHON_EXECUTABLE can be set to the path of a Python 2.x interpreter.
47
   Clay uses a Python 2 script to drive its test suite. Some platforms
48
@@ -70,7 +70,7 @@ and the MSVC compiler. There are some issues with Debug builds and
49
 LLVM, so both LLVM and Clay will need to be built as Release. The
50
 default LLVM install directory needs Administrator permissions, so
51
 you may want to set a CMAKE_INSTALL_PREFIX as well. to change it.
52
-Place the Clang repository in llvm-3.1/tools/clang so that LLVM builds
53
+Place the Clang repository in llvm-3.2/tools/clang so that LLVM builds
54
 it automatically and compile LLVM with the following commands:
55
 
56
     mkdir build
57
diff --git a/compiler/src/clay.hpp b/compiler/src/clay.hpp
58
index 339b262..2c95623 100644
59
--- a/compiler/src/clay.hpp
60
+++ b/compiler/src/clay.hpp
61
@@ -27,8 +27,6 @@
62
 #endif
63
 
64
 #include <llvm/ADT/Triple.h>
65
-#include <llvm/Analysis/DebugInfo.h>
66
-#include <llvm/Analysis/DIBuilder.h>
67
 #include <llvm/Assembly/Writer.h>
68
 #include <llvm/Assembly/Parser.h>
69
 #include <llvm/Assembly/PrintModulePass.h>
70
@@ -36,12 +34,16 @@
71
 #include <llvm/Bitcode/ReaderWriter.h>
72
 #include <llvm/CodeGen/LinkAllAsmWriterComponents.h>
73
 #include <llvm/CodeGen/LinkAllCodegenComponents.h>
74
+#include <llvm/DataLayout.h>
75
+#include <llvm/DebugInfo.h>
76
 #include <llvm/DerivedTypes.h>
77
+#include <llvm/DIBuilder.h>
78
 #include <llvm/ExecutionEngine/ExecutionEngine.h>
79
 #include <llvm/ExecutionEngine/GenericValue.h>
80
 #include <llvm/ExecutionEngine/JIT.h>
81
 #include <llvm/Function.h>
82
 #include <llvm/Intrinsics.h>
83
+#include <llvm/IRBuilder.h>
84
 #include <llvm/LinkAllVMCore.h>
85
 #include <llvm/LLVMContext.h>
86
 #include <llvm/Module.h>
87
@@ -50,7 +52,6 @@
88
 #include <llvm/Support/FileSystem.h>
89
 #include <llvm/Support/FormattedStream.h>
90
 #include <llvm/Support/Host.h>
91
-#include <llvm/Support/IRBuilder.h>
92
 #include <llvm/Support/MemoryBuffer.h>
93
 #include <llvm/Support/Path.h>
94
 #include <llvm/Support/PathV2.h>
95
@@ -59,7 +60,6 @@
96
 #include <llvm/Support/TargetSelect.h>
97
 #include <llvm/Support/TargetSelect.h>
98
 #include <llvm/Support/raw_ostream.h>
99
-#include <llvm/Target/TargetData.h>
100
 #include <llvm/Target/TargetOptions.h>
101
 #include <llvm/Transforms/IPO/PassManagerBuilder.h>
102
 #include <llvm/Transforms/IPO.h>
103
@@ -3450,7 +3450,7 @@ static const unsigned short DW_LANG_user_CLAY = 0xC1A4;
104
 
105
 extern llvm::Module *llvmModule;
106
 extern llvm::DIBuilder *llvmDIBuilder;
107
-extern const llvm::TargetData *llvmTargetData;
108
+extern const llvm::DataLayout *llvmDataLayout;
109
 
110
 llvm::PointerType *exceptionReturnType();
111
 llvm::Value *noExceptionReturnValue();
112
diff --git a/compiler/src/codegen.cpp b/compiler/src/codegen.cpp
113
index f6ed737..1fb574e 100644
114
--- a/compiler/src/codegen.cpp
115
+++ b/compiler/src/codegen.cpp
116
@@ -5,7 +5,7 @@ namespace clay {
117
 llvm::Module *llvmModule = NULL;
118
 llvm::DIBuilder *llvmDIBuilder = NULL;
119
 llvm::ExecutionEngine *llvmEngine;
120
-const llvm::TargetData *llvmTargetData;
121
+const llvm::DataLayout *llvmDataLayout;
122
 
123
 static vector<CValuePtr> initializedGlobals;
124
 static CodegenContextPtr constructorsCtx;
125
@@ -2886,7 +2886,10 @@ void codegenCodeBody(InvokeEntryPtr entry)
126
                                llvmModule);
127
 
128
     for (unsigned i = 1; i <= llArgTypes.size(); ++i) {
129
-        llFunc->addAttribute(i, llvm::Attribute::NoAlias);
130
+        llvm::Attributes attrs = llvm::Attributes::get(
131
+            llFunc->getContext(),
132
+            llvm::Attributes::NoAlias);
133
+        llFunc->addAttribute(i, attrs);
134
     }
135
 
136
     entry->llvmFunc = llFunc;
137
@@ -2903,15 +2906,22 @@ void codegenCodeBody(InvokeEntryPtr entry)
138
         for (unsigned i = 0; i < entry->argsKey.size(); ++i) {
139
             llvm::DIType argType = llvmTypeDebugInfo(entry->argsKey[i]);
140
             llvm::DIType argRefType
141
-                = llvmDIBuilder->createReferenceType(argType);
142
+                = llvmDIBuilder->createReferenceType(
143
+                    llvm::dwarf::DW_TAG_reference_type,
144
+                    argType);
145
             debugParamTypes.push_back(argRefType);
146
         }
147
         for (unsigned i = 0; i < entry->returnTypes.size(); ++i) {
148
             llvm::DIType returnType = llvmTypeDebugInfo(entry->returnTypes[i]);
149
             llvm::DIType returnRefType = entry->returnIsRef[i]
150
                 ? llvmDIBuilder->createReferenceType(
151
-                    llvmDIBuilder->createReferenceType(returnType))
152
-                : llvmDIBuilder->createReferenceType(returnType);
153
+                    llvm::dwarf::DW_TAG_reference_type,
154
+                    llvmDIBuilder->createReferenceType(
155
+                        llvm::dwarf::DW_TAG_reference_type,
156
+                        returnType))
157
+                : llvmDIBuilder->createReferenceType(
158
+                    llvm::dwarf::DW_TAG_reference_type,
159
+                    returnType);
160
 
161
             debugParamTypes.push_back(returnRefType);
162
         }
163
@@ -2983,6 +2993,7 @@ void codegenCodeBody(InvokeEntryPtr entry)
164
                 file, // file
165
                 line, // line
166
                 llvmDIBuilder->createReferenceType(
167
+                    llvm::dwarf::DW_TAG_reference_type,
168
                     llvmTypeDebugInfo(entry->fixedArgTypes[i])), // type
169
                 true, // alwaysPreserve
170
                 0, // flags
171
@@ -3025,6 +3036,7 @@ void codegenCodeBody(InvokeEntryPtr entry)
172
                     file, // file
173
                     line, // line
174
                     llvmDIBuilder->createReferenceType(
175
+                        llvm::dwarf::DW_TAG_reference_type,
176
                         llvmTypeDebugInfo(entry->varArgTypes[i])), // type
177
                     true, // alwaysPreserve
178
                     0, // flags
179
@@ -3084,6 +3096,7 @@ void codegenCodeBody(InvokeEntryPtr entry)
180
                     file, // file
181
                     line, // line
182
                     llvmDIBuilder->createReferenceType(
183
+                        llvm::dwarf::DW_TAG_reference_type,
184
                         llvmTypeDebugInfo(returns[i].type)), // type
185
                     true, // alwaysPreserve
186
                     0, // flags
187
@@ -4076,6 +4089,7 @@ EnvPtr codegenBinding(BindingPtr x, EnvPtr env, CodegenContextPtr ctx)
188
                     file, // file
189
                     line, // line
190
                     llvmDIBuilder->createReferenceType(
191
+                        llvm::dwarf::DW_TAG_reference_type,
192
                         llvmTypeDebugInfo(pv->type)), // type
193
                     true, // alwaysPreserve
194
                     0, // flags
195
@@ -4133,6 +4147,7 @@ EnvPtr codegenBinding(BindingPtr x, EnvPtr env, CodegenContextPtr ctx)
196
                     pv->isTemp
197
                         ? llvmTypeDebugInfo(pv->type)
198
                         : llvmDIBuilder->createReferenceType(
199
+                            llvm::dwarf::DW_TAG_reference_type,
200
                             llvmTypeDebugInfo(pv->type)), // type
201
                     true, // alwaysPreserve
202
                     0, // flags
203
@@ -6464,8 +6479,8 @@ llvm::TargetMachine *initLLVM(std::string const &targetTriple,
204
         targetTriple, "", "", llvm::TargetOptions(), reloc, codeModel);
205
 
206
     if (targetMachine != NULL) {
207
-        llvmTargetData = targetMachine->getTargetData();
208
-        llvmModule->setDataLayout(llvmTargetData->getStringRepresentation());
209
+        llvmDataLayout = targetMachine->getDataLayout();
210
+        llvmModule->setDataLayout(llvmDataLayout->getStringRepresentation());
211
     }
212
 
213
     return targetMachine;
214
diff --git a/compiler/src/externals.cpp b/compiler/src/externals.cpp
215
index f7cd333..ba43797 100644
216
--- a/compiler/src/externals.cpp
217
+++ b/compiler/src/externals.cpp
218
@@ -23,11 +23,12 @@ static llvm::Value *promoteCVarArg(CallingConv conv,
219
     }
220
     case FLOAT_TYPE : {
221
         FloatType *ft = (FloatType *)t.ptr();
222
-        if (ft->bits == 32)
223
+        if (ft->bits == 32) {
224
             if(ft->isImaginary)
225
                 return ctx->builder->CreateFPExt(llv, llvmType(imag64Type));
226
             else
227
                 return ctx->builder->CreateFPExt(llv, llvmType(float64Type));
228
+        }
229
         return llv;
230
     }
231
     default :
232
@@ -43,8 +44,12 @@ llvm::Type *ExternalTarget::pushReturnType(CallingConv conv,
233
     if (type == NULL)
234
         return llvmVoidType();
235
     else if (typeReturnsBySretPointer(conv, type)) {
236
-        llArgTypes.push_back(llvmPointerType(type));
237
-        llAttributes.push_back(make_pair(llArgTypes.size(), llvm::Attribute::StructRet));
238
+        llvm::Type *llType = llvmPointerType(type);
239
+        llArgTypes.push_back(llType);
240
+        llvm::Attributes attrs = llvm::Attributes::get(
241
+            llType->getContext(),
242
+            llvm::Attributes::StructRet);
243
+        llAttributes.push_back(make_pair(llArgTypes.size(), attrs));
244
         return llvmVoidType();
245
     } else {
246
         llvm::Type *bitcastType = typeReturnsAsBitcastType(conv, type);
247
@@ -61,8 +66,12 @@ void ExternalTarget::pushArgumentType(CallingConv conv,
248
                                       vector< pair<unsigned, llvm::Attributes> > &llAttributes)
249
 {
250
     if (typePassesByByvalPointer(conv, type, false)) {
251
-        llArgTypes.push_back(llvmPointerType(type));
252
-        llAttributes.push_back(make_pair(llArgTypes.size(), llvm::Attribute::ByVal));
253
+        llvm::Type *llType = llvmPointerType(type);
254
+        llArgTypes.push_back(llType);
255
+        llvm::Attributes attrs = llvm::Attributes::get(
256
+            llType->getContext(),
257
+            llvm::Attributes::ByVal);
258
+        llAttributes.push_back(make_pair(llArgTypes.size(), attrs));
259
     } else {
260
         llvm::Type *bitcastType = typePassesAsBitcastType(conv, type, false);
261
         if (bitcastType != NULL)
262
@@ -171,7 +180,10 @@ void ExternalTarget::loadStructRetArgument(CallingConv conv,
263
         CValuePtr out0 = out->values[0];
264
         assert(out0->type == type);
265
         llArgs.push_back(out0->llValue);
266
-        llAttributes.push_back(make_pair(llArgs.size(), llvm::Attribute::StructRet));
267
+        llvm::Attributes attrs = llvm::Attributes::get(
268
+            out0->llValue->getContext(),
269
+            llvm::Attributes::StructRet);
270
+        llAttributes.push_back(make_pair(llArgs.size(), attrs));
271
     }
272
 }
273
 
274
@@ -183,7 +195,10 @@ void ExternalTarget::loadArgument(CallingConv conv,
275
 {
276
     if (typePassesByByvalPointer(conv, cv->type, false)) {
277
         llArgs.push_back(cv->llValue);
278
-        llAttributes.push_back(make_pair(llArgs.size(), llvm::Attribute::ByVal));
279
+        llvm::Attributes attrs = llvm::Attributes::get(
280
+            cv->llValue->getContext(),
281
+            llvm::Attributes::ByVal);
282
+        llAttributes.push_back(make_pair(llArgs.size(), attrs));
283
     } else {
284
         llvm::Type *bitcastType = typePassesAsBitcastType(conv, cv->type, false);
285
         if (bitcastType != NULL) {
286
@@ -206,7 +221,10 @@ void ExternalTarget::loadVarArgument(CallingConv conv,
287
 {
288
     if (typePassesByByvalPointer(conv, cv->type, true)) {
289
         llArgs.push_back(cv->llValue);
290
-        llAttributes.push_back(make_pair(llArgs.size(), llvm::Attribute::ByVal));
291
+        llvm::Attributes attrs = llvm::Attributes::get(
292
+            cv->llValue->getContext(),
293
+            llvm::Attributes::ByVal);
294
+        llAttributes.push_back(make_pair(llArgs.size(), attrs));
295
     } else {
296
         llvm::Type *bitcastType = typePassesAsBitcastType(conv, cv->type, true);
297
         if (bitcastType != NULL) {
298
@@ -845,21 +863,26 @@ llvm::Type *X86_64_ExternalTarget::llvmWordType(TypePtr type)
299
     llvm::StructType *llType = llvm::StructType::create(llvm::getGlobalContext(), "x86-64 " + typeName(type));
300
     vector<llvm::Type*> llWordTypes;
301
     vector<WordClass>::const_iterator i = wordClasses.begin();
302
+    size_t size = typeSize(type);
303
     while (i != wordClasses.end()) {
304
+        assert(size > 0);
305
         switch (*i) {
306
         // docs don't cover this case. is it possible?
307
         // e.g. struct { __m128 a; __m256 b; };
308
         case NO_CLASS:
309
             assert(false);
310
             break;
311
-        case INTEGER:
312
-            llWordTypes.push_back(llvmIntType(64));
313
+        case INTEGER: {
314
+            size_t wordSize = size >= 8 ? 64 : size*8;
315
+            llWordTypes.push_back(llvmIntType(wordSize));
316
             ++i;
317
             break;
318
+        }
319
         case SSE_INT_VECTOR: {
320
             int vectorRun = 0;
321
             do { ++vectorRun; ++i; } while (i != wordClasses.end() && *i == SSEUP);
322
-            // 8-byte int vectors are allocated to MMX registers
323
+            // 8-byte int vectors are allocated to MMX registers, so always generate
324
+            // a <float x n> vector for 64-bit SSE words.
325
             if (vectorRun == 1)
326
                 llWordTypes.push_back(llvm::VectorType::get(llvmFloatType(64), vectorRun));
327
             else
328
@@ -913,6 +936,8 @@ llvm::Type *X86_64_ExternalTarget::llvmWordType(TypePtr type)
329
             assert(false);
330
             break;
331
         }
332
+        assert(size >= 8 || i == wordClasses.end());
333
+        size -= 8;
334
     }
335
     llType->setBody(llWordTypes);
336
     return llType;
337
diff --git a/compiler/src/loader.cpp b/compiler/src/loader.cpp
338
index cd90f58..78b6a18 100644
339
--- a/compiler/src/loader.cpp
340
+++ b/compiler/src/loader.cpp
341
@@ -70,8 +70,8 @@ static std::string getCPU(llvm::Triple const &triple) {
342
     }
343
 }
344
 
345
-static std::string getPtrSize(const llvm::TargetData *targetData) {
346
-    switch (targetData->getPointerSizeInBits()) {
347
+static std::string getPtrSize(const llvm::DataLayout *dataLayout) {
348
+    switch (dataLayout->getPointerSizeInBits()) {
349
     case 32 : return "32";
350
     case 64 : return "64";
351
     default : assert(false); return "";
352
@@ -84,7 +84,7 @@ static void initModuleSuffixes() {
353
     string os = getOS(triple);
354
     string osgroup = getOSGroup(triple);
355
     string cpu = getCPU(triple);
356
-    string bits = getPtrSize(llvmTargetData);
357
+    string bits = getPtrSize(llvmDataLayout);
358
     moduleSuffixes.push_back("." + os + "." + cpu + "." + bits + ".clay");
359
     moduleSuffixes.push_back("." + os + "." + cpu + ".clay");
360
     moduleSuffixes.push_back("." + os + "." + bits + ".clay");
361
diff --git a/compiler/src/main.cpp b/compiler/src/main.cpp
362
index f2fbd85..a24c20f 100644
363
--- a/compiler/src/main.cpp
364
+++ b/compiler/src/main.cpp
365
@@ -72,12 +72,12 @@
366
     llvm::PassManager passes;
367
 
368
     string moduleDataLayout = module->getDataLayout();
369
-    llvm::TargetData *td = new llvm::TargetData(moduleDataLayout);
370
-    passes.add(td);
371
+    llvm::DataLayout *dl = new llvm::DataLayout(moduleDataLayout);
372
+    passes.add(dl);
373
 
374
     llvm::FunctionPassManager fpasses(module);
375
 
376
-    fpasses.add(new llvm::TargetData(*td));
377
+    fpasses.add(new llvm::DataLayout(*dl));
378
 
379
     addOptimizationPasses(passes, fpasses, optLevel, internalize);
380
 
381
@@ -116,7 +116,7 @@
382
 
383
     llvm::FunctionPassManager fpasses(module);
384
 
385
-    fpasses.add(new llvm::TargetData(module));
386
+    fpasses.add(new llvm::DataLayout(module));
387
     fpasses.add(llvm::createVerifierPass());
388
 
389
     targetMachine->setAsmVerbosityDefault(true);
390
@@ -180,7 +180,7 @@
391
     vector<const char *> clangArgs;
392
     clangArgs.push_back(clangPath.c_str());
393
 
394
-    switch (llvmTargetData->getPointerSizeInBits()) {
395
+    switch (llvmDataLayout->getPointerSizeInBits()) {
396
     case 32 :
397
         clangArgs.push_back("-m32");
398
         break;
399
@@ -943,7 +943,7 @@
400
             clangPath = llvm::sys::Path();
401
 #endif
402
         if (!clangPath.isValid()) {
403
-            clangPath = llvm::sys::Program::FindProgramByName("clang");
404
+            clangPath = llvm::sys::Program::FindProgramByName("clang32");
405
         }
406
         if (!clangPath.isValid()) {
407
             cerr << "error: unable to find clang on the path\n";
408
diff --git a/compiler/src/types.cpp b/compiler/src/types.cpp
409
index 8f86faa..6990a15 100644
410
--- a/compiler/src/types.cpp
411
+++ b/compiler/src/types.cpp
412
@@ -43,11 +43,11 @@ static vector<vector<StaticTypePtr> > staticTypes;
413
 //
414
 
415
 static size_t llTypeSize(llvm::Type *llt) {
416
-    return (size_t)llvmTargetData->getTypeAllocSize(llt);
417
+    return (size_t)llvmDataLayout->getTypeAllocSize(llt);
418
 }
419
 
420
 static size_t llTypeAlignment(llvm::Type *llt) {
421
-    return (size_t)llvmTargetData->getABITypeAlignment(llt);
422
+    return (size_t)llvmDataLayout->getABITypeAlignment(llt);
423
 }
424
 
425
 static size_t debugTypeSize(llvm::Type *llt) {
426
@@ -81,7 +81,7 @@ void initTypes() {
427
     complex80Type = new ComplexType(80);
428
 
429
     cIntType = int32Type;
430
-    switch (llvmTargetData->getPointerSizeInBits()) {
431
+    switch (llvmDataLayout->getPointerSizeInBits()) {
432
     case 32 :
433
         cSizeTType = uint32Type;
434
         cPtrDiffTType = int32Type;
435
@@ -826,7 +826,7 @@ const llvm::StructLayout *tupleTypeLayout(TupleType *t) {
436
     if (t->layout == NULL) {
437
         llvm::StructType *st =
438
             llvm::cast<llvm::StructType>(llvmType(t));
439
-        t->layout = llvmTargetData->getStructLayout(st);
440
+        t->layout = llvmDataLayout->getStructLayout(st);
441
     }
442
     return t->layout;
443
 }
444
@@ -835,7 +835,7 @@ const llvm::StructLayout *complexTypeLayout(ComplexType *t) {
445
     if (t->layout == NULL) {
446
         llvm::StructType *st =
447
             llvm::cast<llvm::StructType>(llvmType(t));
448
-        t->layout = llvmTargetData->getStructLayout(st);
449
+        t->layout = llvmDataLayout->getStructLayout(st);
450
     }
451
     return t->layout;
452
 }
453
@@ -844,7 +844,7 @@ const llvm::StructLayout *recordTypeLayout(RecordType *t) {
454
     if (t->layout == NULL) {
455
         llvm::StructType *st =
456
             llvm::cast<llvm::StructType>(llvmType(t));
457
-        t->layout = llvmTargetData->getStructLayout(st);
458
+        t->layout = llvmDataLayout->getStructLayout(st);
459
     }
460
     return t->layout;
461
 }
462
@@ -1101,15 +1101,22 @@ static void declareLLVMType(TypePtr t) {
463
             for (unsigned i = 0; i < x->argTypes.size(); ++i) {
464
                 llvm::DIType argType = llvmTypeDebugInfo(x->argTypes[i]);
465
                 llvm::DIType argRefType
466
-                    = llvmDIBuilder->createReferenceType(argType);
467
+                    = llvmDIBuilder->createReferenceType(
468
+                        llvm::dwarf::DW_TAG_reference_type,
469
+                        argType);
470
                 debugParamTypes.push_back(argRefType);
471
             }
472
             for (unsigned i = 0; i < x->returnTypes.size(); ++i) {
473
                 llvm::DIType returnType = llvmTypeDebugInfo(x->returnTypes[i]);
474
                 llvm::DIType returnRefType = x->returnIsRef[i]
475
                     ? llvmDIBuilder->createReferenceType(
476
-                        llvmDIBuilder->createReferenceType(returnType))
477
-                    : llvmDIBuilder->createReferenceType(returnType);
478
+                        llvm::dwarf::DW_TAG_reference_type,
479
+                        llvmDIBuilder->createReferenceType(
480
+                            llvm::dwarf::DW_TAG_reference_type,
481
+                            returnType))
482
+                    : llvmDIBuilder->createReferenceType(
483
+                        llvm::dwarf::DW_TAG_reference_type,
484
+                        returnType);
485
 
486
                 debugParamTypes.push_back(returnRefType);
487
             }
488
@@ -1259,7 +1266,8 @@ static void declareLLVMType(TypePtr t) {
489
                 line,
490
                 debugTypeSize(t->llType),
491
                 debugTypeAlignment(t->llType),
492
-                enumArray);
493
+                enumArray,
494
+                llvm::DIType());
495
         }
496
         break;
497
     }
498
@@ -1358,8 +1366,8 @@ static void defineLLVMType(TypePtr t) {
499
         size_t maxSize = 0;
500
         for (unsigned i = 0; i < x->memberTypes.size(); ++i) {
501
             llvm::Type *llt = llvmType(x->memberTypes[i]);
502
-            size_t align = (size_t)llvmTargetData->getABITypeAlignment(llt);
503
-            size_t size = (size_t)llvmTargetData->getTypeAllocSize(llt);
504
+            size_t align = (size_t)llvmDataLayout->getABITypeAlignment(llt);
505
+            size_t size = (size_t)llvmDataLayout->getTypeAllocSize(llt);
506
             if (align > maxAlign) {
507
                 maxAlign = align;
508
                 maxAlignType = llt;

Return to bug 182497