[llvm-dev] Issues with new Attributor (replaceAllUses fails with type mismatch)

Mani, Suresh via llvm-dev llvm-dev at lists.llvm.org
Fri May 15 05:17:14 PDT 2020


[AMD Public Use]

Hi ,

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

Thanks
M Suresh

From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of Mani, Suresh via llvm-dev
Sent: Friday, May 15, 2020 4:37 PM
To: llvm-dev at lists.llvm.org
Subject: [llvm-dev] Issues with new Attributor (replaceAllUses fails with type mismatch)

[CAUTION: External Email]

[AMD Official Use Only - Internal Distribution Only]

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)  .
------------------------------------------------------------------------------------------------------------------------------------------------------------------


Sample situation 2:

Original code in IR --     %63 = tail call %struct.cv* bitcast (%struct.cv.231* (i8, i64, i32*)* @Perl_find_runcv_where to %struct.cv* (i8, i64, i32*)*)(i8 zeroext 1, i64 %62, i32* null) #14
Attribute info ----   attributes #14 = { nounwind }

Debug info:
OldCB --- %63 = tail call %struct.cv.231* @Perl_find_runcv_where(i8 zeroext 1, i64 %62) #14
NewCB ---%64 = tail call %struct.cv* bitcast (%struct.cv.231* (i8, i64, i32*)* @15 to %struct.cv* (i8, i64, i32*)*)(i8 zeroext 1, i64 %62, i32* noalias align 536870912 null) #14

And hence OldCB.replaceAllUsesWith(&NewCB);   fails
------------------------------------------------------------------------------------------------------------------------------------------------------------------

The complete IR file is very huge, and had no luck in getting a reduced test case.

Thanks
M Suresh




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200515/49ce64b3/attachment.html>


More information about the llvm-dev mailing list