Migration help required for 3.3 to 3.8

I'm migrating from 3.3 to 3.8 and am having a few problems.

`CreateStructGEP` requires a type parameter now. I'm not sure what type it's expecting, so I converted `CreateStructGEP( valuePtr, index )` to `CreateStructGEP( valuePtr->getType(), valuePtr, index )`... would that be correct?

`arg_iterator` no longer converst to Value*, I have a lot of this now:
    &*(args++)
This seems like I'm doing something wrong. Is there a more correct way to convert to the `Value*`?

`PassManager` is now a tample type with `IRUnitT`. What is the `IRUnitT` type? Or rather, how should I be creating the `PassManager`?

Why does `EngineBuilder` require a `unique_ptr` for the `Module` now? After I create the builder I still need to reference the module, in
particular to run the pass manager and look up functions to run. Same for `linker::linkInModule`.

`createBasicAliasAnalyisPass` is gone. What is the replacement, or do I not need it anymore (I believe it was required to be run for other passes).

`linkInModule` used to provide an error message output. Is there a way to get the error now that it is gone?

`CreateStructGEP` requires a type parameter now. I'm not sure what type it's expecting, so I converted `CreateStructGEP( valuePtr, index )` to `CreateStructGEP( valuePtr->getType(), valuePtr, index )`... would that be correct?

This is part of an in-progress move to untyped pointers. if you're
executing a gep on "type*", the type that'll be needed is "type".
Which is probably "valuePtr->getType()->getElementType()" in your
case.

`arg_iterator` no longer converst to Value*, I have a lot of this now:
    &*(args++)
This seems like I'm doing something wrong. Is there a more correct way to convert to the `Value*`?

This looks right. Duncan removed the implicit conversions as part of a refactor.

`PassManager` is now a tample type with `IRUnitT`. What is the `IRUnitT` type? Or rather, how should I be creating the `PassManager`?

The pass manager you're used to has been renamed "LegacyPassManager"
as we're working on a new implementation (templated, as you see). For
the initial migration it's best to just use LegacyPassManager.

Why does `EngineBuilder` require a `unique_ptr` for the `Module` now? After I create the builder I still need to reference the module, in particular to run the pass manager and look up functions to run. Same for `linker::linkInModule`.

Because EngineBuilder takes ownership of the module and deletes it
afterwards. It's still fine to keep your own pointer to the Module.

`createBasicAliasAnalyisPass` is gone. What is the replacement, or do I not need it anymore (I believe it was required to be run for other passes).

`linkInModule` used to provide an error message output. Is there a way to get the error now that it is gone?

I'm afraid I'm not familiar with these.

Cheers.

Tim.

This is part of an in-progress move to untyped pointers. if you're
executing a gep on "type*", the type that'll be needed is "type".
Which is probably "valuePtr->getType()->getElementType()" in your case.

To confirm, the type parameter for CreateStructGEP is the resulting
type, not the source structure type?

The pass manager you're used to has been renamed "LegacyPassManager"
as we're working on a new implementation (templated, as you see). For
the initial migration it's best to just use LegacyPassManager.

One related issue, I used to add the DataLayout to the pass manager like
this:
    fpm.add( new llvm::DataLayout( ee->getDataLayout() ) );

Where `ee` is the ExecutionEngine. Is there a replacement to setting the
DataLayout -- note I'm just using defaults for all data layouts now, so
I don't need to set this if it's implied now.

Because EngineBuilder takes ownership of the module and deletes it
afterwards. It's still fine to keep your own pointer to the Module.

Should there not be a `getModule` function on the EngineBuilder (and
Linker) in this case? To me passing a `unique_ptr` kind of implies I've
given up all control of my original pointer. Using my own copy past that
point feels like an error.

Thanks for the answers.

From: llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org] On Behalf Of edA-qa mort-ora-y via llvm-dev
Subject: Re: [llvm-dev] Migration help required for 3.3 to 3.8

To confirm, the type parameter for CreateStructGEP is the resulting
type, not the source structure type?

No, it's the type of the source structure - the type that used to be inherent in the ptr argument.

One related issue, I used to add the DataLayout to the pass manager like
this:
    fpm.add( new llvm::DataLayout( ee->getDataLayout() ) );

The DataLayout is now set in the Module; we use something like this:
    pMod->setDataLayout(target_machine->createDataLayout());

Not sure what happens if you don't make the call; I would not let it just default.

> Because EngineBuilder takes ownership of the module and deletes it
> afterwards. It's still fine to keep your own pointer to the Module.

Should there not be a `getModule` function on the EngineBuilder (and
Linker) in this case?

There can be more than one Module in play.

To me passing a `unique_ptr` kind of implies I've given up all control
of my original pointer.

Not all control, just ownership.

- Chuck