Browse code

Fix some compiler warnings.

Török Edvin authored on 2009/12/17 17:58:38
Showing 1 changed files
... ...
@@ -175,6 +175,8 @@ public:
175 175
 		case DArrayType:
176 176
 		    Ty = ArrayType::get(Elts[0], type->numElements);
177 177
 		    break;
178
+		default:
179
+		    llvm_unreachable("type->kind");
178 180
 	    }
179 181
 	    // Make the opaque type a concrete type, doing recursive type
180 182
 	    // unification if needed.
... ...
@@ -199,21 +201,24 @@ private:
199 199
     const struct cli_bc *bc;
200 200
     Module *M;
201 201
     LLVMContext &Context;
202
+    ExecutionEngine *EE;
203
+    FunctionPassManager ±
202 204
     LLVMTypeMapper *TypeMap;
205
+
203 206
     Function **apiFuncs;
204
-    FunctionMapTy &compiledFunctions;
205 207
     LLVMTypeMapper &apiMap;
208
+    FunctionMapTy &compiledFunctions;
206 209
     Twine BytecodeID;
207
-    ExecutionEngine *EE;
210
+
208 211
     TargetFolder Folder;
209 212
     IRBuilder<false, TargetFolder> Builder;
213
+
210 214
     std::vector<Value*> globals;
215
+    DenseMap<unsigned, unsigned> GVoffsetMap;
216
+    DenseMap<unsigned, const Type*> GVtypeMap;
211 217
     Value **Values;
212
-    FunctionPassManager &PM;
213 218
     unsigned numLocals;
214 219
     unsigned numArgs;
215
-    DenseMap<unsigned, unsigned> GVoffsetMap;
216
-    DenseMap<unsigned, const Type*> GVtypeMap;
217 220
     std::vector<MDNode*> mdnodes;
218 221
 
219 222
     Value *getOperand(const struct cli_bc_func *func, const Type *Ty, operand_t operand)
... ...
@@ -305,6 +310,8 @@ private:
305 305
 		Ty = Type::getInt64Ty(Context);
306 306
 		v = *(uint64_t*)c;
307 307
 		break;
308
+	    default:
309
+		llvm_unreachable("width");
308 310
 	}
309 311
 	return ConstantInt::get(Ty, v);
310 312
     }
... ...
@@ -375,7 +382,7 @@ private:
375 375
 	   return ConstantStruct::get(STy, elements);
376 376
 	}
377 377
 	Ty->dump();
378
-	assert(0 && "Not reached");
378
+	llvm_unreachable("invalid type");
379 379
 	return 0;
380 380
     }
381 381
 
... ...
@@ -384,11 +391,11 @@ public:
384 384
     LLVMCodegen(const struct cli_bc *bc, Module *M, FunctionMapTy &cFuncs,
385 385
 		ExecutionEngine *EE, FunctionPassManager &PM,
386 386
 		Function **apiFuncs, LLVMTypeMapper &apiMap)
387
-	: bc(bc), M(M), Context(M->getContext()), compiledFunctions(cFuncs),
388
-	BytecodeID("bc"+Twine(bc->id)), EE(EE),
389
-	Folder(EE->getTargetData()), Builder(Context, Folder), PM(PM),
390
-	apiFuncs(apiFuncs), apiMap(apiMap)
391
-    {
387
+	: bc(bc), M(M), Context(M->getContext()), EE(EE),
388
+	PM(PM), apiFuncs(apiFuncs),apiMap(apiMap),
389
+	compiledFunctions(cFuncs), BytecodeID("bc"+Twine(bc->id)),
390
+	Folder(EE->getTargetData()), Builder(Context, Folder) {
391
+
392 392
 	for (unsigned i=0;i<cli_apicall_maxglobal - _FIRST_GLOBAL;i++) {
393 393
 	    unsigned id = cli_globals[i].globalid;
394 394
 	    GVoffsetMap[id] = cli_globals[i].offset;
... ...
@@ -478,7 +485,7 @@ public:
478 478
 	FHandler->setDoesNotReturn();
479 479
 	FHandler->setDoesNotThrow();
480 480
 	FHandler->addFnAttr(Attribute::NoInline);
481
-	EE->addGlobalMapping(FHandler, (void*)jit_exception_handler);
481
+	EE->addGlobalMapping(FHandler, (void*)(intptr_t)jit_exception_handler);
482 482
 
483 483
 	std::vector<const Type*> args;
484 484
 	args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context)));
... ...
@@ -512,13 +519,13 @@ public:
512 512
 	FunctionType* DummyTy = FunctionType::get(Type::getVoidTy(Context), false);
513 513
 	Function *FRealMemset = Function::Create(DummyTy, GlobalValue::ExternalLinkage,
514 514
 						 "memset", M);
515
-	EE->addGlobalMapping(FRealMemset, (void*)memset);
515
+	EE->addGlobalMapping(FRealMemset, (void*)(intptr_t)memset);
516 516
 	Function *FRealMemmove = Function::Create(DummyTy, GlobalValue::ExternalLinkage,
517 517
 						 "memmove", M);
518
-	EE->addGlobalMapping(FRealMemmove, (void*)memmove);
518
+	EE->addGlobalMapping(FRealMemmove, (void*)(intptr_t)memmove);
519 519
 	Function *FRealMemcpy = Function::Create(DummyTy, GlobalValue::ExternalLinkage,
520 520
 						 "memcpy", M);
521
-	EE->addGlobalMapping(FRealMemcpy, (void*)memcpy);
521
+	EE->addGlobalMapping(FRealMemcpy, (void*)(intptr_t)memcpy);
522 522
 
523 523
 	args.clear();
524 524
 	args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context)));
... ...
@@ -527,7 +534,7 @@ public:
527 527
 	FunctionType* FuncTy_5 = FunctionType::get(Type::getInt32Ty(Context),
528 528
 						   args, false);
529 529
 	Function* FRealMemcmp = Function::Create(FuncTy_5, GlobalValue::ExternalLinkage, "memcmp", M);
530
-	EE->addGlobalMapping(FRealMemcmp, (void*)memcmp);
530
+	EE->addGlobalMapping(FRealMemcmp, (void*)(intptr_t)memcmp);
531 531
 
532 532
 	// The hidden ctx param to all functions
533 533
 	const Type *HiddenCtx = PointerType::getUnqual(Type::getInt8Ty(Context));
... ...
@@ -591,7 +598,7 @@ public:
591 591
 	    Values = new Value*[func->numValues];
592 592
 	    Builder.SetInsertPoint(BB[0]);
593 593
 	    Function::arg_iterator I = F->arg_begin();
594
-	    assert(F->arg_size() == func->numArgs + 1 && "Mismatched args");
594
+	    assert(F->arg_size() == (unsigned)(func->numArgs + 1) && "Mismatched args");
595 595
 	    ++I;
596 596
 	    for (unsigned i=0;i<func->numArgs; i++) {
597 597
 		assert(I != F->arg_end());
... ...
@@ -611,7 +618,6 @@ public:
611 611
 
612 612
 	    if (FakeGVs.any()) {
613 613
 		Argument *Ctx = F->arg_begin();
614
-		struct cli_bc_ctx *N = 0;
615 614
 		for (unsigned i=0;i<bc->num_globals;i++) {
616 615
 		    if (!FakeGVs[i])
617 616
 			continue;
... ...
@@ -859,7 +865,6 @@ public:
859 859
 			case OP_BC_CALL_API:
860 860
 			{
861 861
 			    assert(inst->u.ops.funcid < cli_apicall_maxapi && "APICall out of range");
862
-			    const struct cli_apicall *api = &cli_apicalls[inst->u.ops.funcid];
863 862
 			    std::vector<Value*> args;
864 863
 			    Function *DestF = apiFuncs[inst->u.ops.funcid];
865 864
 			    args.push_back(&*F->arg_begin()); // pass hidden arg
... ...
@@ -1051,8 +1056,8 @@ int cli_vm_execute_jit(const struct cli_all_bc *bcs, struct cli_bc_ctx *ctx,
1051 1051
     // execute;
1052 1052
     if (setjmp(env) == 0) {
1053 1053
 	// setup exception handler to longjmp back here
1054
-	ExceptionReturn.set(&env);
1055
-	uint32_t result = ((uint32_t (*)(struct cli_bc_ctx *))code)(ctx);
1054
+	ExceptionReturn.set((const jmp_buf*)&env);
1055
+	uint32_t result = ((uint32_t (*)(struct cli_bc_ctx *))(intptr_t)code)(ctx);
1056 1056
 	*(uint32_t*)ctx->values = result;
1057 1057
 	return 0;
1058 1058
     }
... ...
@@ -1069,7 +1074,7 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
1069 1069
       return CL_EBYTECODE;
1070 1070
   jmp_buf env;
1071 1071
   // setup exception handler to longjmp back here
1072
-  ExceptionReturn.set(&env);
1072
+  ExceptionReturn.set((const jmp_buf*)&env);
1073 1073
   if (setjmp(env) != 0) {
1074 1074
       errs() << "\n";
1075 1075
       errs().changeColor(raw_ostream::RED, true) << MODULE 
... ...
@@ -1124,11 +1129,13 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
1124 1124
 	    void *dest;
1125 1125
 	    switch (api->kind) {
1126 1126
 		case 0:
1127
-		    dest = (void*)cli_apicalls0[api->idx];
1127
+		    dest = (void*)(intptr_t)cli_apicalls0[api->idx];
1128 1128
 		    break;
1129 1129
 		case 1:
1130
-		    dest = (void*)cli_apicalls1[api->idx];
1130
+		    dest = (void*)(intptr_t)cli_apicalls1[api->idx];
1131 1131
 		    break;
1132
+		default:
1133
+		    llvm_unreachable("invalid api type");
1132 1134
 	    }
1133 1135
 	    EE->addGlobalMapping(F, dest);
1134 1136
 	    apiFuncs[i] = F;
... ...
@@ -1221,13 +1228,13 @@ void cli_bytecode_debug(int argc, char **argv)
1221 1221
   cl::ParseCommandLineOptions(argc, argv);
1222 1222
 }
1223 1223
 
1224
-struct lines {
1224
+typedef struct lines {
1225 1225
     MemoryBuffer *buffer;
1226 1226
     std::vector<const char*> linev;
1227
-};
1227
+} linesTy;
1228 1228
 
1229 1229
 static struct lineprinter {
1230
-    StringMap<struct lines*> files;
1230
+    StringMap<linesTy*> files;
1231 1231
 } LinePrinter;
1232 1232
 
1233 1233
 void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx)
... ...
@@ -1241,10 +1248,10 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx)
1241 1241
     sys::SmartScopedLock<false> lock(mtx);
1242 1242
 
1243 1243
     std::string path = std::string(ctx->directory) + "/" + std::string(ctx->file);
1244
-    StringMap<struct lines*>::iterator I = LinePrinter.files.find(path);
1245
-    struct lines *lines;
1244
+    StringMap<linesTy*>::iterator I = LinePrinter.files.find(path);
1245
+    linesTy *lines;
1246 1246
     if (I == LinePrinter.files.end()) {
1247
-	lines = new struct lines;
1247
+	lines = new linesTy;
1248 1248
 	std::string ErrorMessage;
1249 1249
 	lines->buffer = MemoryBuffer::getFile(path, &ErrorMessage);
1250 1250
 	if (!lines->buffer) {