Skip to content

Commit f7cbdfd

Browse files
committed
chore: aggregate PRs
This PR aggregates changes from the following PRs: - Closes #11957 by @\MozirDmitriy - Closes #11954 by @\anim001k - Closes #11953 by @\strmfos - Closes #11939 by @\silvekkk
1 parent 93e6755 commit f7cbdfd

File tree

8 files changed

+119
-23
lines changed

8 files changed

+119
-23
lines changed

a.ll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
define noundef i64 @give_asm(ptr noalias noundef nonnull readonly align 1 captures(none) %slice.0, i64 noundef %slice.1) unnamed_addr #39 {
2+
start:
3+
%_26.not = icmp eq i64 %slice.1, 0
4+
br i1 %_26.not, label %bb7, label %bb3
5+
6+
bb7: ; preds = %bb3, %start
7+
%pc.sroa.0.0.lcssa = phi i64 [ 0, %start ], [ %3, %bb3 ]
8+
ret i64 %pc.sroa.0.0.lcssa
9+
10+
bb3: ; preds = %start, %bb3
11+
%pc.sroa.0.07 = phi i64 [ %3, %bb3 ], [ 0, %start ]
12+
%0 = getelementptr inbounds nuw i8, ptr %slice.0, i64 %pc.sroa.0.07
13+
%opcode = load i8, ptr %0, align 1, !noundef !22
14+
%1 = tail call i8 @llvm.smax.i8(i8 %opcode, i8 95)
15+
%imm.sroa.0.0 = add nsw i8 %1, -95
16+
%_11 = zext nneg i8 %imm.sroa.0.0 to i64
17+
%2 = add nuw i64 %pc.sroa.0.07, 1
18+
%3 = add i64 %2, %_11
19+
%_2 = icmp ult i64 %3, %slice.1
20+
br i1 %_2, label %bb3, label %bb7
21+
}

b.ll

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
define noundef i64 @give_asm(ptr noalias noundef nonnull readonly align 1 captures(address, read_provenance) %slice.0, i64 noundef %slice.1) unnamed_addr #39 personality ptr @rust_eh_personality {
2+
start:
3+
%_8.i16.i = icmp samesign eq i64 %slice.1, 0
4+
br i1 %_8.i16.i, label %bb5, label %bb2.i.i.preheader
5+
6+
bb2.i.i.preheader: ; preds = %start
7+
%_10 = getelementptr inbounds nuw i8, ptr %slice.0, i64 %slice.1
8+
%0 = ptrtoint ptr %_10 to i64
9+
br label %bb2.i.i
10+
11+
bb2.i.i: ; preds = %bb2.i.i.preheader, %bb3.i
12+
%1 = phi i64 [ %6, %bb3.i ], [ 0, %bb2.i.i.preheader ]
13+
%_8.sroa.7.0.i.i1418.i = phi ptr [ %5, %bb3.i ], [ %slice.0, %bb2.i.i.preheader ]
14+
%_14.i.i = getelementptr inbounds nuw i8, ptr %_8.sroa.7.0.i.i1418.i, i64 1
15+
%_6.val.i.i = load i8, ptr %_8.sroa.7.0.i.i1418.i, align 1, !noalias !62783, !noundef !22
16+
%2 = tail call i8 @llvm.smax.i8(i8 %_6.val.i.i, i8 95)
17+
%narrow.i.i.i = add nsw i8 %2, -95
18+
%_5.sroa.0.0.i.i.i = zext nneg i8 %narrow.i.i.i to i64
19+
%3 = ptrtoint ptr %_14.i.i to i64
20+
%4 = sub nuw i64 %0, %3
21+
%_22.not.i.i.i = icmp ult i64 %4, %_5.sroa.0.0.i.i.i
22+
br i1 %_22.not.i.i.i, label %bb5, label %bb3.i
23+
24+
bb3.i: ; preds = %bb2.i.i
25+
%5 = getelementptr inbounds nuw i8, ptr %_14.i.i, i64 %_5.sroa.0.0.i.i.i
26+
%_21.i.i = add i64 %1, 1
27+
%6 = add i64 %_21.i.i, %_5.sroa.0.0.i.i.i
28+
%_8.i.i = icmp eq i64 %4, %_5.sroa.0.0.i.i.i
29+
br i1 %_8.i.i, label %bb5, label %bb2.i.i
30+
31+
bb5: ; preds = %bb3.i, %bb2.i.i, %start
32+
%_0.sroa.0.0 = phi i64 [ 0, %start ], [ %1, %bb2.i.i ], [ %1, %bb3.i ]
33+
ret i64 %_0.sroa.0.0
34+
}

c.ll

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
define noundef i64 @give_asm(ptr noalias noundef nonnull readonly align 1 captures(address, read_provenance) %slice.0, i64 noundef %slice.1) unnamed_addr #39 personality ptr @rust_eh_personality {
2+
start:
3+
%_8.i7 = icmp samesign eq i64 %slice.1, 0
4+
br i1 %_8.i7, label %bb5, label %bb2.i.preheader
5+
6+
bb2.i.preheader: ; preds = %start
7+
%_12 = getelementptr inbounds nuw i8, ptr %slice.0, i64 %slice.1
8+
br label %bb2.i
9+
10+
bb2.i: ; preds = %bb2.i.preheader, %bb2.i
11+
%iter.sroa.0.010 = phi ptr [ %_8.sroa.7.0.i.i, %bb2.i ], [ %slice.0, %bb2.i.preheader ]
12+
%iter.sroa.5.09 = phi ptr [ %_28.i.i, %bb2.i ], [ %_12, %bb2.i.preheader ]
13+
%iter.sroa.8.08 = phi i64 [ %6, %bb2.i ], [ 0, %bb2.i.preheader ]
14+
%_14.i = getelementptr inbounds nuw i8, ptr %iter.sroa.0.010, i64 1
15+
%_6.val.i = load i8, ptr %iter.sroa.0.010, align 1, !noalias !62783, !noundef !22
16+
%0 = tail call i8 @llvm.smax.i8(i8 %_6.val.i, i8 95)
17+
%narrow.i.i = add nsw i8 %0, -95
18+
%_5.sroa.0.0.i.i = zext nneg i8 %narrow.i.i to i64
19+
%1 = ptrtoint ptr %iter.sroa.5.09 to i64
20+
%2 = ptrtoint ptr %_14.i to i64
21+
%3 = sub nuw i64 %1, %2
22+
%_22.not.i.i = icmp ult i64 %3, %_5.sroa.0.0.i.i
23+
%4 = getelementptr inbounds nuw i8, ptr %_14.i, i64 %_5.sroa.0.0.i.i
24+
%5 = add nuw nsw i64 %_5.sroa.0.0.i.i, 1
25+
%_8.sroa.9.0.i.i = call i64 @llvm.usub.sat.i64(i64 %3, i64 %_5.sroa.0.0.i.i)
26+
%_8.sroa.7.0.i.i = select i1 %_22.not.i.i, ptr inttoptr (i64 1 to ptr), ptr %4
27+
%_8.sroa.5.0.i.i = select i1 %_22.not.i.i, i64 1, i64 %5
28+
%_28.i.i = getelementptr inbounds nuw i8, ptr %_8.sroa.7.0.i.i, i64 %_8.sroa.9.0.i.i
29+
%6 = add i64 %_8.sroa.5.0.i.i, %iter.sroa.8.08
30+
%_8.i.not = icmp ugt i64 %3, %_5.sroa.0.0.i.i
31+
br i1 %_8.i.not, label %bb2.i, label %bb5
32+
33+
bb5: ; preds = %bb2.i, %start
34+
%pc.sroa.0.0.lcssa = phi i64 [ 0, %start ], [ %iter.sroa.8.08, %bb2.i ]
35+
ret i64 %pc.sroa.0.0.lcssa
36+
}

crates/anvil/src/eth/backend/db.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,14 @@ impl<T: DatabaseRef<Error = DatabaseError> + Debug> MaybeFullDatabase for CacheD
256256
}
257257

258258
fn read_as_state_snapshot(&self) -> StateSnapshot {
259-
let db_accounts = self.cache.accounts.clone();
260259
let mut accounts = HashMap::default();
261260
let mut account_storage = HashMap::default();
262261

263-
for (addr, acc) in db_accounts {
264-
account_storage.insert(addr, acc.storage.clone());
265-
let mut info = acc.info;
262+
for (addr, acc) in &self.cache.accounts {
263+
account_storage.insert(*addr, acc.storage.clone());
264+
let mut info = acc.info.clone();
266265
info.code = self.cache.contracts.get(&info.code_hash).cloned();
267-
accounts.insert(addr, info);
266+
accounts.insert(*addr, info);
268267
}
269268

270269
let block_hashes = self.cache.block_hashes.clone();

crates/anvil/src/eth/backend/mem/mod.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,7 +2229,7 @@ impl Backend {
22292229

22302230
fn mined_block_by_hash(&self, hash: B256) -> Option<AnyRpcBlock> {
22312231
let block = self.blockchain.get_block_by_hash(&hash)?;
2232-
Some(self.convert_block(block))
2232+
Some(self.convert_block_with_hash(block, Some(hash)))
22332233
}
22342234

22352235
pub(crate) async fn mined_transactions_by_block_number(
@@ -2298,7 +2298,8 @@ impl Backend {
22982298
Ok(None)
22992299
}
23002300

2301-
pub fn get_block(&self, id: impl Into<BlockId>) -> Option<Block> {
2301+
/// Returns the block and its hash for the given id
2302+
fn get_block_with_hash(&self, id: impl Into<BlockId>) -> Option<(Block, B256)> {
23022303
let hash = match id.into() {
23032304
BlockId::Hash(hash) => hash.block_hash,
23042305
BlockId::Number(number) => {
@@ -2326,36 +2327,46 @@ impl Backend {
23262327
}
23272328
}
23282329
};
2329-
self.get_block_by_hash(hash)
2330+
let block = self.get_block_by_hash(hash)?;
2331+
Some((block, hash))
2332+
}
2333+
2334+
pub fn get_block(&self, id: impl Into<BlockId>) -> Option<Block> {
2335+
self.get_block_with_hash(id).map(|(block, _)| block)
23302336
}
23312337

23322338
pub fn get_block_by_hash(&self, hash: B256) -> Option<Block> {
23332339
self.blockchain.get_block_by_hash(&hash)
23342340
}
23352341

23362342
pub fn mined_block_by_number(&self, number: BlockNumber) -> Option<AnyRpcBlock> {
2337-
let block = self.get_block(number)?;
2338-
let mut block = self.convert_block(block);
2343+
let (block, hash) = self.get_block_with_hash(number)?;
2344+
let mut block = self.convert_block_with_hash(block, Some(hash));
23392345
block.transactions.convert_to_hashes();
23402346
Some(block)
23412347
}
23422348

23432349
pub fn get_full_block(&self, id: impl Into<BlockId>) -> Option<AnyRpcBlock> {
2344-
let block = self.get_block(id)?;
2350+
let (block, hash) = self.get_block_with_hash(id)?;
23452351
let transactions = self.mined_transactions_in_block(&block)?;
2346-
let mut block = self.convert_block(block);
2352+
let mut block = self.convert_block_with_hash(block, Some(hash));
23472353
block.inner.transactions = BlockTransactions::Full(transactions);
2348-
23492354
Some(block)
23502355
}
23512356

23522357
/// Takes a block as it's stored internally and returns the eth api conform block format.
23532358
pub fn convert_block(&self, block: Block) -> AnyRpcBlock {
2359+
self.convert_block_with_hash(block, None)
2360+
}
2361+
2362+
/// Takes a block as it's stored internally and returns the eth api conform block format.
2363+
/// If `known_hash` is provided, it will be used instead of computing `hash_slow()`.
2364+
pub fn convert_block_with_hash(&self, block: Block, known_hash: Option<B256>) -> AnyRpcBlock {
23542365
let size = U256::from(alloy_rlp::encode(&block).len() as u32);
23552366

23562367
let Block { header, transactions, .. } = block;
23572368

2358-
let hash = header.hash_slow();
2369+
let hash = known_hash.unwrap_or_else(|| header.hash_slow());
23592370
let Header { number, withdrawals_root, .. } = header;
23602371

23612372
let block = AlloyBlock {

crates/chisel/src/solidity_helper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl Default for SolidityHelper {
5151

5252
impl fmt::Debug for SolidityHelper {
5353
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54-
let this = self.inner.borrow_mut();
54+
let this = self.inner.borrow();
5555
f.debug_struct("SolidityHelper")
5656
.field("errored", &this.errored)
5757
.field("do_paint", &this.do_paint)

npm/src/const.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@ export type Platform = Extract<
1616
'darwin' | 'linux' | 'win32'
1717
>
1818

19-
/**
20-
* foundry doesn't ship arm64 binaries for windows
21-
*/
22-
export type ArchitecturePlatform = Exclude<
23-
`${Platform}-${Architecture}`,
24-
'win32-arm64'
25-
>
19+
// Note: we intentionally don't export a combined `Platform-Architecture` alias here,
20+
// since only specific pairs are supported (see `BINARY_DISTRIBUTION_PACKAGES`).
2621

2722
export const BINARY_DISTRIBUTION_PACKAGES = {
2823
darwin: {

npm/src/install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function extractFileFromTarball(
105105
if (fileName === filepath)
106106
return tarballBuffer.subarray(offset, offset + fileSize)
107107

108-
// Clamp offset to the uppoer multiple of 512
108+
// Clamp offset to the upper multiple of 512
109109
offset = (offset + fileSize + 511) & ~511
110110
}
111111
throw new Error(`File ${filepath} not found in tarball`)

0 commit comments

Comments
 (0)