StructReturnToPointer in poolalloc failing with LLVM 3.4

Hi,

I've been happily using DSA in a project of mine for quite a while
now, and recently I noticed that the functionality of
StructReturnToPointer could be useful to me as well.

So I tried using it on a simple example, but I keep getting the
following exception:

smack: /home/zvonimir/projects/smack-project/llvm/src/lib/IR/Attributes.cpp:912:
unsigned int llvm::AttributeSet::getSlotIndex(unsigned int) const:
Assertion `pImpl && Slot < pImpl->getNumAttributes() && "Slot # out of
range!"' failed.
0 smack 0x0000000000a38982 llvm::sys::PrintStackTrace(_IO_FILE*) + 34
1 smack 0x0000000000a37d69
2 libpthread.so.0 0x00007fc770d81cb0
3 libc.so.6 0x00007fc76fdab425 gsignal + 53
4 libc.so.6 0x00007fc76fdaeb8b abort + 379
5 libc.so.6 0x00007fc76fda40ee
6 libc.so.6 0x00007fc76fda4192
7 smack 0x000000000090164f
8 smack 0x000000000099a984
llvm::Argument::addAttr(llvm::AttributeSet) + 36
9 smack 0x000000000050f294
llvm::StructRet::runOnModule(llvm::Module&) + 2180
10 smack 0x00000000009c2e1f
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 927
11 smack 0x000000000048d448 main + 840
12 libc.so.6 0x00007fc76fd9676d __libc_start_main + 237

Basically, there is a problem with the following piece of code, and I
suspect it might be due to upgrading to LLVM 3.4:
    ValueToValueMapTy ValueMap;
    Function::arg_iterator NI = NF->arg_begin();
    NI->setName("ret");
    ++NI;
    for (Function::arg_iterator II = F->arg_begin(); II !=
F->arg_end(); ++II, ++NI) {
      ValueMap[II] = NI;
      NI->setName(II->getName());
      NI->addAttr(F->getAttributes().getParamAttributes(II->getArgNo() + 1));
    }

I've tried to fix this, but no luck so far, and so help would be great
appreciated.

Thanks!

-- Zvonimir

Hi,

I've been happily using DSA in a project of mine for quite a while
now, and recently I noticed that the functionality of
StructReturnToPointer could be useful to me as well.

DSA isn't supported for LLVM 3.4 yet. The release_32 branch works with LLVM 3.2, and I think the trunk branch compiles with LLVM 3.3 (although I haven't used that branch much myself yet).

If you want to use DSA, you'll either need to update it to work with LLVM 3.4 or stick with an earlier version of LLVM with which it works.

As far as your specific question on the attribute code, I'm not sufficiently familiar with LLVM 3.4 to know why it's not working. If I had to take a guess, I'd say that you might want to dump F->getAttributes().getParamAttributes(II->getArgNo()) to see if the "+ 1" in the last line is an off-by-one error.

Sorry I don't know what wrong with particular piece of code,

John Criswell