[PATCH][ARM] Fix assertion failure in SjLjEHPrepare
Kai Nacke
kai at redstar.de
Wed May 8 09:19:25 PDT 2013
Hi!
Compiling any code containing EH code for -march=arm -mtriple=arm-darwin
results in the following assertion failure:
Assertion failed: getOperand(0)->getType() ==
cast<PointerType>(getOperand(1)->g
etType())->getElementType() && "Ptr must be a pointer to Val type!",
file D:\Ope
nSource\LLVM\llvm-git\lib\IR\Instructions.cpp, line 1084
Stack dump:
0. Program arguments: llc -filetype=obj exc.ll -march=arm
-mtriple=arm-darw
in
1. Running pass 'Function Pass Manager' on module 'exc.ll'.
2. Running pass 'SJLJ Exception Handling preparation' on function
'@_Dmain'
Root cause is that the type of the personality function is defined by
user code but treated as void pointer in the SjLj prepare pass.
The attached patch adds a bitcast to prevent this failure. Please review.
Regards
Kai
-------------- next part --------------
diff --git a/lib/CodeGen/SjLjEHPrepare.cpp b/lib/CodeGen/SjLjEHPrepare.cpp
index 3903743..23984e9 100644
--- a/lib/CodeGen/SjLjEHPrepare.cpp
+++ b/lib/CodeGen/SjLjEHPrepare.cpp
@@ -222,7 +222,9 @@ setupFunctionContext(Function &F, ArrayRef<LandingPadInst*> LPads) {
PersonalityFn = LPads[0]->getPersonalityFn();
Value *PersonalityFieldPtr = Builder.CreateConstGEP2_32(FuncCtx, 0, 3,
"pers_fn_gep");
- Builder.CreateStore(PersonalityFn, PersonalityFieldPtr, /*isVolatile=*/true);
+ Builder.CreateStore(Builder.CreateBitCast(PersonalityFn,
+ Builder.getInt8PtrTy()),
+ PersonalityFieldPtr, /*isVolatile=*/true);
// LSDA address
Value *LSDA = Builder.CreateCall(LSDAAddrFn, "lsda_addr");
More information about the llvm-commits
mailing list