@@ -187,9 +187,12 @@ void linkLibdevice(llvm::Module *M, const std::string &path) {
187187 seqassertn (!fail, " linking libdevice failed" );
188188}
189189
190- llvm::Function *copyPrototype (llvm::Function *F, const std::string &name) {
190+ llvm::Function *copyPrototype (llvm::Function *F, const std::string &name,
191+ bool external = false ) {
191192 auto *M = F->getParent ();
192- return llvm::Function::Create (F->getFunctionType (), llvm::GlobalValue::PrivateLinkage,
193+ return llvm::Function::Create (F->getFunctionType (),
194+ external ? llvm::GlobalValue::ExternalLinkage
195+ : llvm::GlobalValue::PrivateLinkage,
193196 name.empty () ? F->getName () : name, *M);
194197}
195198
@@ -651,7 +654,7 @@ void remapFunctions(llvm::Module *M) {
651654 } else {
652655 G = M->getFunction (pair.second );
653656 if (!G)
654- G = copyPrototype (F, pair.second );
657+ G = copyPrototype (F, pair.second , /* external= */ true );
655658 }
656659
657660 G->setWillReturn ();
@@ -712,6 +715,12 @@ std::string moduleToPTX(llvm::Module *M, std::vector<llvm::GlobalValue *> &kerne
712715 llvm::codegen::getExplicitRelocModel (), llvm::codegen::getExplicitCodeModel (),
713716 llvm::CodeGenOptLevel::Aggressive));
714717
718+ // Remove personality functions
719+ for (auto &F : *M) {
720+ F.setDoesNotThrow ();
721+ F.setPersonalityFn (nullptr );
722+ }
723+
715724 M->setDataLayout (machine->createDataLayout ());
716725 auto keep = getRequiredGVs (kernels);
717726
0 commit comments