Skip to content

Virtual reverse constexpr test triggers assertion #752

@tgymnich

Description

@tgymnich

The constexpr test added by @ZuseZ4 in #743 triggers assertions. They just don't show up in our CI.

 @_ZTId = external dso_local constant i8*

 define i8* @_ZNK4implIdE4typeEv()  {
   ret i8* bitcast (i8** @_ZTId to i8*)
 }

 declare void @_Z17__enzyme_virtualreverse(i8*)

 define void @_Z18wrapper_1body_intsv()  {
   call void @_Z17__enzyme_virtualreverse(i8* bitcast (i8* ()* @_ZNK4implIdE4typeEv to i8*))
   ret void
 }
    for (auto pair : toVirtual) {
      auto CI = pair.first;
      Constant *fn = dyn_cast<Constant>(CI->getArgOperand(0));
      if (!fn) {
        EmitFailure("IllegalVirtual", CI->getDebugLoc(), CI,
                    "Cannot create virtual version of non-constant value ", *CI,
                    *CI->getArgOperand(0));
        return false;
      }
      TypeAnalysis TA(Logic.PPC.FAM);

      auto Arch =
          llvm::Triple(
              CI->getParent()->getParent()->getParent()->getTargetTriple())
              .getArch();

      bool AtomicAdd = Arch == Triple::nvptx || Arch == Triple::nvptx64 ||
                       Arch == Triple::amdgcn;

      auto val = GradientUtils::GetOrCreateShadowConstant(
          Logic, TLI, TA, fn, pair.second, /*width*/ 1, AtomicAdd);
      CI->replaceAllUsesWith(ConstantExpr::getPointerCast(val, CI->getType()));
      CI->eraseFromParent();
      Changed = true;
    }

CI->getType() => void
val->getType() => i8*

Originally posted by @tgymnich in #743 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions