OSDN Git Service

Fixed warnings in Reactor
authorAlexis Hetu <sugoi@google.com>
Thu, 19 Jan 2017 15:49:19 +0000 (10:49 -0500)
committerAlexis Hétu <sugoi@google.com>
Thu, 19 Jan 2017 16:20:22 +0000 (16:20 +0000)
Fixed:
- type comparison mismatch
- redefined macros
- unused functions
- line endings

Change-Id: I965ca4b887aee968e6cf95feb36c3cbf90b85580
Reviewed-on: https://swiftshader-review.googlesource.com/8528
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/Reactor/Optimizer.cpp
src/Reactor/SubzeroReactor.cpp

index ca3d7a3..75b225e 100644 (file)
@@ -135,7 +135,7 @@ namespace
 
                                        for(Ice::Inst *use : uses[loadData])
                                        {
-                                               for(int i = 0; i < use->getSrcSize(); i++)
+                                               for(Ice::SizeT i = 0; i < use->getSrcSize(); i++)
                                                {
                                                        if(use->getSrc(i) == loadData)
                                                        {
@@ -201,7 +201,7 @@ namespace
 
                                        replace(load, storeValue);
 
-                                       for(int i = 0; i < addressUses.loads.size(); i++)
+                                       for(size_t i = 0; i < addressUses.loads.size(); i++)
                                        {
                                                if(addressUses.loads[i] == load)
                                                {
@@ -211,7 +211,7 @@ namespace
                                                }
                                        }
 
-                                       for(int i = 0; i < addressUses.size(); i++)
+                                       for(size_t i = 0; i < addressUses.size(); i++)
                                        {
                                                if(addressUses[i] == load)
                                                {
@@ -231,7 +231,7 @@ namespace
 
                                                auto &valueUses = uses[storeValue];
 
-                                               for(int i = 0; i < valueUses.size(); i++)
+                                               for(size_t i = 0; i < valueUses.size(); i++)
                                                {
                                                        if(valueUses[i] == store)
                                                        {
@@ -280,7 +280,7 @@ namespace
 
                        Ice::CfgNode *singleBasicBlock = node[addressUses.stores[0]];
 
-                       for(int i = 1; i < addressUses.stores.size(); i++)
+                       for(size_t i = 1; i < addressUses.stores.size(); i++)
                        {
                                Ice::Inst *store = addressUses.stores[i];
                                if(node[store] != singleBasicBlock)
@@ -356,9 +356,9 @@ namespace
                                node[&instruction] = basicBlock;
                                definition[instruction.getDest()] = &instruction;
 
-                               for(int i = 0; i < instruction.getSrcSize(); i++)
+                               for(Ice::SizeT i = 0; i < instruction.getSrcSize(); i++)
                                {
-                                       int unique = 0;
+                                       Ice::SizeT unique = 0;
                                        for(; unique < i; unique++)
                                        {
                                                if(instruction.getSrc(i) == instruction.getSrc(unique))
@@ -390,7 +390,7 @@ namespace
                {
                        assert(!use->isDeleted());   // Should have been removed from uses already
 
-                       for(int i = 0; i < use->getSrcSize(); i++)
+                       for(Ice::SizeT i = 0; i < use->getSrcSize(); i++)
                        {
                                if(use->getSrc(i) == oldValue)
                                {
@@ -415,7 +415,7 @@ namespace
 
                instruction->setDeleted();
 
-               for(int i = 0; i < instruction->getSrcSize(); i++)
+               for(Ice::SizeT i = 0; i < instruction->getSrcSize(); i++)
                {
                        Ice::Operand *src = instruction->getSrc(i);
 
@@ -583,14 +583,14 @@ namespace
        {
                auto &uses = *this;
 
-               for(int i = 0; i < uses.size(); i++)
+               for(size_t i = 0; i < uses.size(); i++)
                {
                        if(uses[i] == instruction)
                        {
                                uses[i] = back();
                                pop_back();
 
-                               for(int i = 0; i < loads.size(); i++)
+                               for(size_t i = 0; i < loads.size(); i++)
                                {
                                        if(loads[i] == instruction)
                                        {
@@ -600,7 +600,7 @@ namespace
                                        }
                                }
 
-                               for(int i = 0; i < stores.size(); i++)
+                               for(size_t i = 0; i < stores.size(); i++)
                                {
                                        if(stores[i] == instruction)
                                        {
index 07c486f..2a5bad0 100644 (file)
 #include "llvm/Support/raw_os_ostream.h"
 
 #if defined(_WIN32)
+#ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
+#endif // !WIN32_LEAN_AND_MEAN
+#ifndef NOMINMAX
 #define NOMINMAX
+#endif // !NOMINMAX
 #include <Windows.h>
 #else
 #include <sys/mman.h>
@@ -109,7 +113,7 @@ namespace sw
 
        Ice::Type T(Type *t)
        {
-               static_assert(Ice::IceType_NUM < EmulatedBits, "Ice::Type overlaps with our emulated types!");
+               static_assert(static_cast<unsigned int>(Ice::IceType_NUM) < static_cast<unsigned int>(EmulatedBits), "Ice::Type overlaps with our emulated types!");
                return (Ice::Type)(reinterpret_cast<std::intptr_t>(t) & ~EmulatedBits);
        }
 
@@ -292,20 +296,20 @@ namespace sw
                        {
                                assert(sizeof(void*) == 4 && "UNIMPLEMENTED");   // Only expected/implemented for 32-bit code
 
-                               for(int index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
+                               for(Elf32_Word index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
                                {
                                        const Elf32_Rel &relocation = ((const Elf32_Rel*)(elfImage + sectionHeader[i].sh_offset))[index];
-                                       void *symbol = relocateSymbol(elfHeader, relocation, sectionHeader[i]);
+                                       relocateSymbol(elfHeader, relocation, sectionHeader[i]);
                                }
                        }
                        else if(sectionHeader[i].sh_type == SHT_RELA)
                        {
                                assert(sizeof(void*) == 8 && "UNIMPLEMENTED");   // Only expected/implemented for 64-bit code
 
-                               for(int index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
+                               for(Elf32_Word index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
                                {
                                        const Elf64_Rela &relocation = ((const Elf64_Rela*)(elfImage + sectionHeader[i].sh_offset))[index];
-                                       void *symbol = relocateSymbol(elfHeader, relocation, sectionHeader[i]);
+                                       relocateSymbol(elfHeader, relocation, sectionHeader[i]);
                                }
                        }
                }
@@ -683,15 +687,6 @@ namespace sw
                return createArithmetic(Ice::InstArithmetic::Xor, lhs, rhs);
        }
 
-       static Ice::Variable *createAssign(Ice::Operand *constant)
-       {
-               Ice::Variable *value = ::function->makeVariable(constant->getType());
-               auto assign = Ice::InstAssign::create(::function, value, constant);
-               ::basicBlock->appendInst(assign);
-
-               return value;
-       }
-
        Value *Nucleus::createNeg(Value *v)
        {
                return createSub(createNullValue(T(v->getType())), v);