Issue 57290
Summary llvm::CloneModule bug "Referencing global in another module!"
Labels new issue
Assignees
Reporter Hatsunespica
    Test case:
```
@i1 = ifunc void (), void ()* ()* @f1

define void ()* @f1() {
  %i1 = bitcast void ()* @i1 to i8*
}

```



Test code:
```
std::shared_ptr<llvm::Module> openInputFile(const string &inputFile,
                                            llvm::LLVMContext &context) {
  llvm::ExitOnError ExitOnErr;
  auto MB =
      ExitOnErr(errorOrToExpected(llvm::MemoryBuffer::getFile(inputFile)));
  llvm::SMDiagnostic Diag;
  auto pm = getLazyIRModule(std::move(MB), Diag, context,
                            /*ShouldLazyLoadMetadata=*/true);
  if (!pm) {
    Diag.print("", llvm::errs(), false);
    return nullptr;
  }
  ExitOnErr(pm->materializeAll());
  return std::move(pm);
}

void handle(std::shared_ptr<llvm::Module> ptr) {
  std::shared_ptr<llvm::Module> newModule=llvm::CloneModule(*ptr,vmap);
  llvm::verifyModule(*newModule,&llvm::errs());
}

void test(){
  llvm::LLVMContext context;
  std::shared_ptr<llvm::Module> pm = openInputFile(testfile, context);
  handle(pm);
}
```

Verifier output:
```
Referencing global in another module!
  %i1 = bitcast void ()* @i1 to i8*
; ModuleID = '/home/spica/test.ll'
void ()* @i1
; ModuleID = '/home/spica/test.ll'
Referencing global in another module!
  %i2 = bitcast void ()* @i2 to i8*
; ModuleID = '/home/spica/test.ll'
void ()* @i2
; ModuleID = '/home/spica/test.ll'
```

Similar to another issue I mentioned before >_<
https://github.com/llvm/llvm-project/issues/55991

cc @regehr 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to