Skip to content

Commit a79a4b6

Browse files
committed
WebAssemblyLowerEmscriptenEHSjLj: move some code to !EnableWasmAltSjLj block
1 parent ea5db86 commit a79a4b6

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,31 +1311,33 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runSjLjOnFunction(Function &F) {
13111311

13121312
// Setjmp preparation
13131313

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.
13181314
BasicBlock *Entry = &F.getEntryBlock();
13191315
DebugLoc FirstDL = getOrCreateDebugLoc(&*Entry->begin(), F.getSubprogram());
13201316
SplitBlock(Entry, &*Entry->getFirstInsertionPt());
13211317

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;
13301319
Instruction *SetjmpTable;
13311320
if (EnableWasmAltSjLj) {
1321+
IRB.SetInsertPoint(Entry->getTerminator());
13321322
// This alloca'ed pointer is used by the runtime to identify function
13331323
// inovactions. It's just for pointer comparisons. It will never
13341324
// be dereferenced.
13351325
SetjmpTable = IRB.CreateAlloca(IRB.getInt32Ty());
13361326
SetjmpTable->setDebugLoc(FirstDL);
13371327
SetjmpTableInsts.push_back(SetjmpTable);
13381328
} 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);
13391341
SetjmpTable = IRB.CreateMalloc(IntPtrTy, IRB.getInt32Ty(), size, nullptr,
13401342
nullptr, "setjmpTable");
13411343
SetjmpTable->setDebugLoc(FirstDL);

0 commit comments

Comments
 (0)