diffs for vc7.1

Hi all,

Here the first bunch of patch for compiling part of LLVM under win32 with MSVC 7.1:

* Trivial addings (I hope!):
- #include <string> at top of:
     llvm\include\llvm\ExecutionEngine\ExecutionEngine.h(78) : error C2039: 'string' : is not a member of '_STL'
- #include <algorithm> at top of:
     llvm\lib\CodeGen\LiveIntervalAnalysis.cpp(639) : error C2039: 'sort' : is not a member of '_STL'
     llvm\lib\CodeGen\RegAllocLinearScan.cpp(473) : error C3861: 'find': identifier not found, even with argument-dependent lookup
     llvm\lib\CodeGen\RegAllocLinearScan.cpp(486) : error C3861: 'find': identifier not found, even with argument-dependent lookup
     llvm\lib\Transforms\Scalar\LoopUnswitch.cpp(261) : error C2039: 'sort' : is not a member of '_STL'
     llvm\lib\Transforms\Scalar\LowerSwitch.cpp(211) : error C2039: 'sort' : is not a member of '_STL'
     llvm\lib\Analysis\BasicAliasAnalysis.cpp(700) : error C2039: 'sort' : is not a member of '_STL'
     llvm\lib\Analysis\IntervalPartition.cpp(29) : error C3861: 'for_each': identifier not found, even with argument-dependent lookup
     llvm\lib\Analysis\LoadValueNumbering.cpp(184) : error C2039: 'sort' : is not a member of '_STL'
     llvm\lib\Analysis\ScalarEvolution.cpp(362) : error C2039: 'sort' : is not a member of '_STL'
     llvm\lib\Transforms\Utils\PromoteMemoryToRegister.cpp(314) : error C2039: 'sort' : is not a member of '_STL'
     llvm\lib\Bytecode\Reader\Reader.cpp(349) : error C3861: 'find': identifier not found, even with argument-dependent lookup

- added std::
     llvm\lib\Analysis\IntervalPartition.cpp(29) : error C3861: 'for_each': identifier not found, even with argument-dependent lookup
     llvm\include\llvm\Analysis\IntervalIterator.h(180) : error C3861: 'make_pair': identifier not found, even with argument-dependent lookup
     llvm\lib\Analysis\LoopInfo.cpp(36) : error C3861: 'find': identifier not found, even with argument-dependent lookup
     llvm\lib\Transforms\Utils\SimplifyCFG.cpp(52) : error C3861: 'find': identifier not found, even with argument-dependent lookup
     build_vc71\lib\Bytecode\Reader\Reader.cpp(356) : error C3861: 'find': identifier not found, even with argument-dependent lookup
     build_vc71\lib\Bytecode\Reader\Reader.cpp(383) : error C3861: 'find': identifier not found, even with argument-dependent lookup

* C99 Arrays... forgive me if I don't provide a patch to standard vectors...
     llvm\lib\Bytecode\Reader\Reader.cpp(1483) : error C2057: expected constant expression
     llvm/lib/CodeGen/LiveVariables.cpp, # MachineInstr *PhysRegInfoA[RegInfo->getNumRegs()]; C99 array
     llvm/lib/Target/TargetSchedInfo.cpp, # int classPairGaps[numSchedClasses][numSchedClasses]; C99 array

The next bigger problem is that the compiler complains about this kind of construct...

<snip>
for (BasicBlock::iterator I = Dest->begin(); PHINode *PN = dyn_cast<PHINode>(I); ++I)
     visitPHINode(*PN);
<snip>

build_vc71\lib\Transforms\Scalar\SCCP.cpp(202) : error C2275: 'llvm::PHINode' : illegal use of this type as an expression

in short, is the assignment in the PHINode *PN = dyn_cast<PHINode>(I) ,as if I break it in:

for (BasicBlock::iterator I = Dest->begin(); dyn_cast<PHINode>(I); ++I) {
     PHINode *PN = dyn_cast<PHINode>(I);
     visitPHINode(*PN);
}

it compiles, and I've found the problem only when used in the 'for' statement (for now...)

So I'm turning my code to

for (BasicBlock::iterator I = Dest->begin(); isa<PHINode>(I); ++I) {
     PHINode *PN = cast<PHINode>(I);
     visitPHINode(*PN);
}

but I think is a NO-NO, so suggestions?

The Visual C++ manual reports:

An expression uses the -> operator with a typedef identifier.
Example
// C2275.cpp
typedef struct S
{
     int mem;
} *S_t;
void func1( int *parm );
void func2()
{
     func1( &S_t->mem ); // C2275, S_t is a typedef
}

diff_include.txt (1.32 KB)

diff_lib.txt (5.34 KB)

I just applied your patches. Keep up the good work! :slight_smile:

Thanks,

Hi Paolo,

<snip>
for (BasicBlock::iterator I = Dest->begin(); PHINode *PN = dyn_cast<PHINode>(I); ++I)
    visitPHINode(*PN);
<snip>

build_vc71\lib\Transforms\Scalar\SCCP.cpp(202) : error C2275: 'llvm::PHINode' : illegal use of this type as an expression

but I think is a NO-NO, so suggestions?

Since it's fussy about a declaration in the for construct, perhaps something like this might work:

PHINode *PN;
for (BasicBlock::iterator I = Dest->begin(); (PN = dyn_cast<PHINode>(I)); ++I)
    ...

However, I haven't worked with Visual C++ and so am not familiar with its peculiarities.

-Anshu

That looks like it should work. Its only the declaration that
it is complaining about. PLease prepare a patch that includes initialization of the PN variable to zero and I will apply the patch.

Reid.

Anshu Dasgupta wrote:

I think what you're arguing are really the same thing.
The for loop uses a dyn_cast<> which returns non-zero on success.
Paolo converted dyn_cast<> to isa<> which returns true precisely when
dyn_cast<> would return non-zero (which is what the for-loop actually
does). So I would say that Paolo's solution is just as valid, and
possibly cleaner, since isa<> returns a bool, while dyn_cast<> returns a
pointer.

I can confirm that both are compiled properly:

A)

PHINode *PN;
for (BasicBlock::iterator I = H->begin(); PN = dyn_cast<PHINode>(I); I++)
     ....

B)

for (BasicBlock::iterator I = H->begin; isa<PHINode>(I); I++) {
     PHINode *PN = cast<PHINode(I);
     ....
}

I'll make a patch for whatever solution do you prefer (this problem is a showstopper for more than a dozen files...)

I can confirm that both are compiled properly:

Ok.

for (BasicBlock::iterator I = H->begin; isa<PHINode>(I); I++) {
     PHINode *PN = cast<PHINode(I);
     ....
}

I'll make a patch for whatever solution do you prefer (this problem is
a showstopper for more than a dozen files...)

I prefer this option (it reduces the scope of the PN variable).

-Chris

Post Scriptum.... please remember I have no access to regression tests
(still <g>) so please keep all my submission with "grano salis"

>>> <snip>
>>> for (BasicBlock::iterator I = Dest->begin(); PHINode *PN =
>>> dyn_cast<PHINode>(I); ++I)
>>> visitPHINode(*PN);
>>> <snip>
>>>
>>> build_vc71\lib\Transforms\Scalar\SCCP.cpp(202) : error C2275:
>>> 'llvm::PHINode' : illegal use of this type as an expression
>>>
>>> but I think is a NO-NO, so suggestions?
>>
>> Since it's fussy about a declaration in the for construct, perhaps
>> something like this might work:
>>
>> PHINode *PN;
>> for (BasicBlock::iterator I = Dest->begin(); (PN =
>> dyn_cast<PHINode>(I)); ++I)
>> ...
>
> I think what you're arguing are really the same thing.
> The for loop uses a dyn_cast<> which returns non-zero on success.
> Paolo converted dyn_cast<> to isa<> which returns true precisely when
> dyn_cast<> would return non-zero (which is what the for-loop actually
> does). So I would say that Paolo's solution is just as valid, and
> possibly cleaner, since isa<> returns a bool, while dyn_cast<> returns
> a
> pointer.
>
> --
> Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev

-Chris

Thanks Chris , I'll prepare the pathes for the weekend.

Hi all,

Attached to this email you can find the diffs versus current CVS that makes all the touched files compile under Microsoft Visual C 7.1

The following libs are now building:
vmcore, transformutils, transform, cwriter, lli-jit, executionengine, selectiondag, modulosched, sched, bcwriter, datastructure, ipa

Next patch will be the conversion of some C99 dynamic array to std::vector, if nobody complains about it...

diff.txt (10 KB)