[llvm] [ExceptionDemo] Transition example from MCJIT to ORC and fix compiling errors (PR #92504)
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 16:32:14 PST 2025
lhames wrote:
Thank you for your patience with this very delayed review!
Your changes look good to me. When I cherry-picked locally I had to resolve a small conflict, and found a couple of deprecation warnings and an error, all caused by changes on the mainline since you wrote your fix:
```c++
/Users/lhames/Projects/llvm/llvm-github/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1283:25: warning: 'getPointerTo' is deprecated: Use PointerType::get instead [-Wdeprecated-declarations]
1283 | ourExceptionType->getPointerTo());
| ^~~~~~~~~~~~
| PointerType::get
/Users/lhames/Projects/llvm/llvm-github/llvm/include/llvm/IR/Type.h:489:3: note: 'getPointerTo' has been explicitly marked deprecated here
489 | LLVM_DEPRECATED("Use PointerType::get instead", "PointerType::get")
| ^
/Users/lhames/Projects/llvm/llvm-github/llvm/include/llvm/Support/Compiler.h:234:50: note: expanded from macro 'LLVM_DEPRECATED'
234 | #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
| ^
/Users/lhames/Projects/llvm/llvm-github/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1547:52: error: reinterpret_cast from 'uint64_t' (aka 'unsigned long long') to 'uintptr_t' (aka 'unsigned long') is not allowed
1547 | reinterpret_cast<OurExceptionThrowFunctType>(reinterpret_cast<uintptr_t>(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1548 | ExitOnErr(JIT->lookup(function)).getValue()));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lhames/Projects/llvm/llvm-github/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1857:3: warning: 'getDeclaration' is deprecated: Use getOrInsertDeclaration instead [-Wdeprecated-declarations]
1857 | getDeclaration(&module, llvm::Intrinsic::eh_typeid_for, builder.getPtrTy());
| ^~~~~~~~~~~~~~
| getOrInsertDeclaration
/Users/lhames/Projects/llvm/llvm-github/llvm/include/llvm/IR/Intrinsics.h:100:3: note: 'getDeclaration' has been explicitly marked deprecated here
100 | LLVM_DEPRECATED("Use getOrInsertDeclaration instead",
| ^
/Users/lhames/Projects/llvm/llvm-github/llvm/include/llvm/Support/Compiler.h:234:50: note: expanded from macro 'LLVM_DEPRECATED'
234 | #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
| ^
2 warnings and 1 error generated.
ninja: build stopped: subcommand failed.
```
After resolving in favor of your commit the following patch resolves the errors and warnings:
```c++
diff --git a/llvm/examples/ExceptionDemo/ExceptionDemo.cpp b/llvm/examples/ExceptionDemo/ExceptionDemo.cpp
index 16f7ab28fa65..d31daed29dc7 100644
--- a/llvm/examples/ExceptionDemo/ExceptionDemo.cpp
+++ b/llvm/examples/ExceptionDemo/ExceptionDemo.cpp
@@ -1280,7 +1280,7 @@ static llvm::Function *createCatchWrappedInvokeFunction(
llvm::Value *typeInfoThrown = builder.CreatePointerCast(
builder.CreateConstGEP1_64(builder.getPtrTy(), unwindException,
ourBaseFromUnwindOffset),
- ourExceptionType->getPointerTo());
+ llvm::PointerType::get(ourExceptionType, 0));
// Retrieve thrown exception type info type
//
@@ -1544,8 +1544,7 @@ static void runExceptionThrow(llvm::orc::LLJIT *JIT, std::string function,
// Find test's function pointer
OurExceptionThrowFunctType functPtr =
- reinterpret_cast<OurExceptionThrowFunctType>(reinterpret_cast<uintptr_t>(
- ExitOnErr(JIT->lookup(function)).getValue()));
+ ExitOnErr(JIT->lookup(function)).toPtr<OurExceptionThrowFunctType>();
try {
// Run test
@@ -1854,7 +1853,8 @@ static void createStandardUtilityFunctions(unsigned numTypeInfos,
// llvm.eh.typeid.for intrinsic
- getDeclaration(&module, llvm::Intrinsic::eh_typeid_for, builder.getPtrTy());
+ getOrInsertDeclaration(
+ &module, llvm::Intrinsic::eh_typeid_for, builder.getPtrTy());
}
```
If you're happy to update your PR I can approve and merge it.
https://github.com/llvm/llvm-project/pull/92504
More information about the llvm-commits
mailing list