We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 05e5de1 commit 36b344cCopy full SHA for 36b344c
lib/Arch/Arch.cpp
@@ -758,7 +758,11 @@ void Arch::InitializeEmptyLiftedFunction(llvm::Function *func) const {
758
llvm::IRBuilder<> ir(block);
759
ir.CreateAlloca(u8, nullptr, "BRANCH_TAKEN");
760
ir.CreateAlloca(addr, nullptr, "RETURN_PC");
761
- ir.CreateAlloca(addr, nullptr, "MONITOR");
+
762
+ // NOTE: we need to start with an initialize MONITOR state,
763
+ // otherwise STLXR without a preceding LDXR/LDAXR will do UB
764
+ auto monitor = ir.CreateAlloca(addr, nullptr, "MONITOR");
765
+ ir.CreateStore(llvm::ConstantInt::get(addr, 0), monitor);
766
767
// NOTE(pag): `PC` and `NEXT_PC` are handled by
768
// `FinishLiftedFunctionInitialization`.
0 commit comments