Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash -e
if [ $# -ne 1 ]; then
echo "Usage: $0 /path/to/output/clang-format"
exit 1
fi
OUTPUT="$1"
if [ -e "$OUTPUT" ]; then
#!/bin/bash -e
LLVM_VERSION=18.1.8
MAKEFLAGS=-j16
if [ $# -ne 1 ]; then
echo "Usage: $0 /path/to/output/clang-format"
exit 1
fi
@ekpyron
ekpyron / clang-format.patch
Last active August 17, 2024 18:34
AlwaysBlockIndent for clang-format
diff -Naur clang-18.1.8.src.orig/include/clang/Format/Format.h clang-18.1.8.src/include/clang/Format/Format.h
--- clang-18.1.8.src.orig/include/clang/Format/Format.h 2024-06-15 19:21:32.000000000 +0200
+++ clang-18.1.8.src/include/clang/Format/Format.h 2024-08-16 02:23:04.288426013 +0200
@@ -97,6 +97,7 @@
/// ``Cpp11BracedListStyle`` is ``true``) and parentheses.
/// \endnote
BAS_BlockIndent,
+ BAS_AlwaysBlockIndent,
};
Optimized IR:
/*=====================================================*
* WARNING *
* Solidity to Yul compilation is still EXPERIMENTAL *
* It can result in LOSS OF FUNDS or worse *
* !USE AT YOUR OWN RISK! *
*=====================================================*/
/// @use-src 0:"test/libsolidity/semanticTests/userDefinedValueType/calldata.sol"
object "C_294" {
diff --git a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp
index 6cd9b45cd..db0dd3007 100644
--- a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp
+++ b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp
@@ -342,7 +342,10 @@ void OptimizedEVMCodeTransform::createStackLayout(Stack _targetStack)
// - the constant 0
// Note: it might even make sense to introduce a specific assembly item for this, s.t.
// the peephole optimizer can deal with this (e.g. POP PUSHJUNK can be removed).
- m_assembly.appendInstruction(evmasm::Instruction::PC);
+ if (m_assembly.stackHeight() == 0)
object "C_46" {
code {
{
/// @src 0:0:160
let _1 := memoryguard(0x80)
mstore(64, _1)
if callvalue() { revert(0, 0) }
let _2 := datasize("C_46_deployed")
codecopy(_1, dataoffset("C_46_deployed"), _2)
return(_1, _2)
@ekpyron
ekpyron / optimized.yul
Created August 23, 2021 11:07
Optimizer Inlining issue.
object "object" {
code {
{
let _1 := mload(sub(shl(137, 1), 1))
let _2 := foo_s_107_268_512_924_1670(sub(shl(125, 1), 1), sub(shl(129, 1), 1), sub(shl(133, 1), 1), _1)
let _3 := mload(sub(shl(105, 1), 1))
let _4 := foo_s_107_268_512_924_1670(sub(shl(101, 1), 1), _3, sub(shl(109, 1), 1), sub(shl(113, 1), 1))
pop(foo_s_107_268_512_924_1670(sub(shl(97, 1), 1), not(foo_s_107_268_512_924_1670(sub(shl(97, 1), 1), not(foo_s_107_268_512_924_1670(sub(shl(97, 1), 1), not(foo_s_107_268_512_924_1670(sub(shl(97, 1), 1), not(foo_s_107_268_512_924_1670(sub(shl(97, 1), 1), not(foo_s_107_268_512_924_1670(sub(shl(97, 1), 1), foo_s_107_268_512_924_1670(sub(shl(101, 1), 1), _3, sub(shl(109, 1), 1), sub(shl(113, 1), 1)), sub(shl(117, 1), 1), addmod(sub(shl(121, 1), 1), foo_s_107_268_512_924_1670(sub(shl(125, 1), 1), sub(shl(129, 1), 1), sub(shl(133, 1), 1), _1), sub(shl(141, 1), 1)))), sub(shl(117, 1), 1), addmod(sub(shl(121, 1), 1), not(foo_s_107_268_512_924
#!/bin/bash
echo '{"contracts": {"test.sol:C": {"asm": {".code": [],".data": {"0":
{".auxdata":"a26469706673582212205fe09eead890659ccd3f8dfd5c787234e5830f5efe2e01ab570bd5d3eb7ce18364736f6c6378263
02e382e372d646576656c6f702e323032312e372e382b636f6d6d69742e30306330666361660057",
".code": [' > /tmp/test.asm
cat $1 | while read OP; do
if [[ $OP == PUSH* ]]; then
VALUE=$(echo $OP | cut -f 2 -d ' ')
echo "{\"begin\": 0,\"end\": 0,\"name\": \"PUSH\",\"source\": 0,\"value\": \"${VALUE}\"}," >>
// test/libsolidity/semanticTests/calldata/calldata_internal_function_pointer.sol --evm-version homestead --optimize
// function call to g() reverts, even though it should not
object "C_71" {
code {
{
mstore(64, 128)
if callvalue() { revert(0, 0) }
sstore(0x00, or(and(sload(0x00), not(sub(exp(2, 64), 1))), 28))
let _1 := datasize("C_71_deployed")
codecopy(128, dataoffset("C_71_deployed"), _1)
template<typename GetTargetPosition, typename Swap, typename Pop>
void permute(unsigned _n, GetTargetPosition _getTargetPosition, Swap _swap, Pop _pop)
{
static_assert(
std::is_same_v<std::invoke_result_t<GetTargetPosition, unsigned>, int>,
"_getTargetPosition needs to have the signature int(unsigned)"
);
static_assert(
std::is_same_v<std::invoke_result_t<Swap, unsigned>, void>,
"_swap needs to have the signature void(unsigned)"