Suzero. X8664. NaCl Sandboxing.
BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4077
R=sehr@chromium.org, stichnot@chromium.org
Review URL: https://codereview.chromium.org/1559243002 .
diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp
index ba50afb..9e3f23a 100644
--- a/src/IceCfgNode.cpp
+++ b/src/IceCfgNode.cpp
@@ -1107,6 +1107,11 @@
return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() ==
InstBundleLock::Opt_AlignToEnd;
}
+ bool isPadToEnd() const {
+ assert(isInBundleLockRegion());
+ return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() ==
+ InstBundleLock::Opt_PadToEnd;
+ }
// Check whether the entire bundle_lock region falls within the same bundle.
bool isSameBundle() const {
assert(isInBundleLockRegion());
@@ -1172,7 +1177,17 @@
}
}
}
- // Update bookkeeping when rolling back for the second pass.
+ // If pad_to_end is specified, add padding such that the first instruction
+ // after the instruction sequence starts at a bundle boundary.
+ void padForPadToEnd() {
+ assert(isInBundleLockRegion());
+ if (isPadToEnd()) {
+ if (intptr_t Offset = getPostAlignment()) {
+ Asm->padWithNop(BundleSize - Offset);
+ SizeSnapshotPre = Asm->getBufferSize();
+ }
+ }
+ } // Update bookkeeping when rolling back for the second pass.
void rollback() {
assert(isInBundleLockRegion());
Asm->setBufferSize(SizeSnapshotPre);
@@ -1261,6 +1276,7 @@
// If align_to_end is specified, make sure the next instruction begins
// the bundle.
assert(!Helper.isAlignToEnd() || Helper.getPostAlignment() == 0);
+ Helper.padForPadToEnd();
Helper.leaveBundleLockRegion();
Retrying = false;
} else {