Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

John Regehr regehr

🎯
Focusing
Block or report user

Report or block regehr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:24560ea4352e11bf6c74a0bc70b8f0e1
#include <iostream>
#include <random>
#include <functional>
#include <map>
namespace {
bool enumerate;
std::random_device rd;
View gist:b2b724ea337c71a2aa7e70315a18c5d1
----------------------------------------
define i64 @slice(i64 %0) {
%1:
%2 = shl i64 9223372036854775807, %0
ret i64 %2
}
=>
define i64 @slice(i64 %rdi) {
%0:
ret i64 -2246371524778917889
View gist:9ccc4fd236e59ea89a1d2503b1951fb5
{
"arch": "amd64",
"os": "linux",
"functions": [
{
"address": 0,
"name": "slice",
"parameters": [
{
"name": "rdi",
View gist:20b66a92d0533e7b7559bcffb1ba8a80
{
"arch": "amd64",
"os": "linux",
"functions": [
{
"address": 0,
"name": "slice",
"parameters": [
{
"name": "edi",
View gist:6a67100cd1f44973fec6d4e20eb45e43
regehr@john-home:~/mctoll/llvm-project/llvm/tools/llvm-mctoll$ creduce --help
creduce 2.10.0 (fb91843) -- a C and C++ program reducer
C-Reduce requires an "interestingness test" and one or more files to
reduce, which must be writable. The interestingness test is an
executable program (usually a shell script) that returns 0 when a
partially reduced file is interesting (a candidate for further
reduction) and returns non-zero when a partially reduced file is not
interesting (not a candidate for further reduction -- all
uninteresting files are discarded).
View gist:ec1237ebe8ade092e4b02424ef4d791d
regehr@john-home:~/remill-build$ ./tools/lift/remill-lift-4.0 -ir_out /dev/stdout --bytes 4889f9b802000000d3c0c3 --slice_inputs RSP,EDI --slice_outputs RAX
; ModuleID = 'lifted_code'
source_filename = "lifted_code"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu-elf"
%struct.Memory = type opaque
%struct.State = type { %struct.ArchState, [32 x %union.VectorReg], %struct.ArithFlags, %union.anon, %struct.Segments, %struct.AddressSpace, %struct.GPR, %struct.X87Stack, %struct.MMX, %struct.FPUStatusFlags, %union.anon, %union.FPU, %struct.SegmentCaches }
%struct.ArchState = type { i32, i32, %union.anon }
%union.VectorReg = type { %union.vec512_t }
View gist:b2ce4e05438aac2d7f5caf1c2e85ef72
89 if (current_clr_polling_and_test()) {
93 arch_cpu_idle();
arch_cpu_idle () at arch/x86/kernel/process.c:571
571 x86_idle();
__x86_indirect_thunk_rax () at arch/x86/lib/retpoline.S:32
32 GENERATE_THUNK(_ASM_AX)
default_idle () at arch/x86/kernel/process.c:578
578 {
579 trace_cpu_idle_rcuidle(1, smp_processor_id());
580 safe_halt();
View pipe.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static void ensure(int x) {
if (x)
return;
printf("ensure failed, exiting\n");
exit(-1);
}
View pipe.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void ensure(int x) {
if (!x) {
printf("ensure failed, exiting\n");
exit(-1);
}
}
View gist:fdf82768f25c9b15d549dd5057be2532
#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
using namespace std;
int main() {
fs::path aPath{"./path/to/file.txt"};
cout << "Parent path: " << aPath.parent_path() << endl;
You can’t perform that action at this time.