Issues with new Attributor (replaceAllUses fails with type mismatch)

Hi ,

There seems to be some issue with attributor, exactly in File Attributor.cpp, Function Attributor::rewriteFunctionSignatures(), Line No: 1600 (approrimate).

The llvm source code at above address is as follows:

// Eliminate the instructions after we visited all of them.

for (auto &CallSitePair : CallSitePairs) {

CallBase &OldCB = *CallSitePair.first;

CallBase &NewCB = *CallSitePair.second;

ModifiedFns.insert(OldCB.getFunction());

CGUpdater.replaceCallSite(OldCB, NewCB);

OldCB.replaceAllUsesWith(&NewCB); ß-------------------------------------- Failing location

OldCB.eraseFromParent();

}

Failure symptom:

Assertion failed: New->getType() == getType() && “replaceAllUses of value with new value of different type!”

Snaps for IR from failing llvm IR and debug info while debugging is as follows:

Sample situation1:

Original code in IR – %133 = call i32 (i32, …) bitcast (void (i32)* @set_yydebug to i32 (i32, …)*)(i32 1) #21

Attribute info ---- attributes #21 = { nounwind }

Debug info:

OldCB-------------------- %133 = call i32 (i32, …) bitcast (void (i32)* @0 to i32 (i32, …)*)(i32 1) #27

NewCB-------------------- call void @set_yydebug() #27

OldCB.replaceAllUsesWith(&NewCB); fails because of a type mismatch b/w OldCB (i32) and NewCB (void) .

[AMD Public Use]

Hi ,

Please ignore the earlier header of Internal and Official use only.

Thanks

M Suresh

Hi Suresh,

thanks for reporting this!

I thought I fixed this with 8d94d3c3b44c3a27a69b153cef9be4b8e481150e.

Did you run before or after that commit?

Cheers,

 Johannes

[AMD Public Use]

Hi Johannes,

This fix (8d94d3c3b44c3a27a69b153cef9be4b8e481150e) does not seem the resolve the issue and the problem still persists.

Regards,

M Suresh

[AMD Public Use]

Hi Johannes,

I took the latest llvm code now and the issue got resolved.

Thanks

M Suresh