@@ -1311,31 +1311,33 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runSjLjOnFunction(Function &F) {
1311
1311
1312
1312
// Setjmp preparation
1313
1313
1314
- // This instruction effectively means %setjmpTableSize = 4.
1315
- // We create this as an instruction intentionally, and we don't want to fold
1316
- // this instruction to a constant 4, because this value will be used in
1317
- // SSAUpdater.AddAvailableValue(...) later.
1318
1314
BasicBlock *Entry = &F.getEntryBlock ();
1319
1315
DebugLoc FirstDL = getOrCreateDebugLoc (&*Entry->begin (), F.getSubprogram ());
1320
1316
SplitBlock (Entry, &*Entry->getFirstInsertionPt ());
1321
1317
1322
- BinaryOperator *SetjmpTableSize =
1323
- BinaryOperator::Create (Instruction::Add, IRB.getInt32 (4 ), IRB.getInt32 (0 ),
1324
- " setjmpTableSize" , Entry->getTerminator ());
1325
- SetjmpTableSize->setDebugLoc (FirstDL);
1326
- // setjmpTable = (int *) malloc(40);
1327
- Type *IntPtrTy = getAddrIntType (&M);
1328
- Constant *size = ConstantInt::get (IntPtrTy, 40 );
1329
- IRB.SetInsertPoint (SetjmpTableSize);
1318
+ BinaryOperator *SetjmpTableSize;
1330
1319
Instruction *SetjmpTable;
1331
1320
if (EnableWasmAltSjLj) {
1321
+ IRB.SetInsertPoint (Entry->getTerminator ());
1332
1322
// This alloca'ed pointer is used by the runtime to identify function
1333
1323
// inovactions. It's just for pointer comparisons. It will never
1334
1324
// be dereferenced.
1335
1325
SetjmpTable = IRB.CreateAlloca (IRB.getInt32Ty ());
1336
1326
SetjmpTable->setDebugLoc (FirstDL);
1337
1327
SetjmpTableInsts.push_back (SetjmpTable);
1338
1328
} else {
1329
+ // This instruction effectively means %setjmpTableSize = 4.
1330
+ // We create this as an instruction intentionally, and we don't want to fold
1331
+ // this instruction to a constant 4, because this value will be used in
1332
+ // SSAUpdater.AddAvailableValue(...) later.
1333
+ SetjmpTableSize = BinaryOperator::Create (Instruction::Add, IRB.getInt32 (4 ),
1334
+ IRB.getInt32 (0 ), " setjmpTableSize" ,
1335
+ Entry->getTerminator ());
1336
+ SetjmpTableSize->setDebugLoc (FirstDL);
1337
+ IRB.SetInsertPoint (SetjmpTableSize);
1338
+ // setjmpTable = (int *) malloc(40);
1339
+ Type *IntPtrTy = getAddrIntType (&M);
1340
+ Constant *size = ConstantInt::get (IntPtrTy, 40 );
1339
1341
SetjmpTable = IRB.CreateMalloc (IntPtrTy, IRB.getInt32Ty (), size, nullptr ,
1340
1342
nullptr , " setjmpTable" );
1341
1343
SetjmpTable->setDebugLoc (FirstDL);
0 commit comments