Skip to content

Instantly share code, notes, and snippets.

View nickdesaulniers's full-sized avatar

Nick Desaulniers (paternity leave) nickdesaulniers

View GitHub Profile
typedef unsigned short __u16;
typedef __u16 u16;
enum { false, true };
typedef _Bool bool;
typedef struct qspinlock {
struct {
struct {
u16 tail;
};
};
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
index 84b87538a15d..92acef97d8ed 100644
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -75,9 +75,11 @@ do { \
*/
#define __WARN_FLAGS(flags) \
do { \
+ __label__ reachable; \
instrumentation_begin(); \
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 4013cf230026..400b7fafd6d7 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -160,26 +160,44 @@ bool arm::isHardTPSupported(const llvm::Triple &Triple) {
// Select mode for reading thread pointer (-mtp=soft/cp15).
arm::ReadTPMode arm::getReadTPMode(const Driver &D, const ArgList &Args,
const llvm::Triple &Triple, bool ForAS) {
+ // Default to Soft.
+ ReadTPMode Mode = ReadTPMode::Soft;
@nickdesaulniers
nickdesaulniers / PPCISelLowering.cpp.diff
Last active December 21, 2021 22:02
diff of llvm/lib/Target/PowerPC/PPCISelLowering.cpp
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index d6ee6a9d6525..4ca72f819301 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -546,11 +546,13 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
setOperationAction(ISD::GlobalAddress, MVT::i32, Custom);
setOperationAction(ISD::GlobalTLSAddress, MVT::i32, Custom);
setOperationAction(ISD::BlockAddress, MVT::i32, Custom);
+ setOperationAction(ISD::TargetBlockAddress, MVT::i32, Custom);
setOperationAction(ISD::ConstantPool, MVT::i32, Custom);
@nickdesaulniers
nickdesaulniers / measure_30.sh
Last active October 28, 2021 19:18
average total cycle counts for 30 runs.
#!/usr/bin/env sh
# Usage: ./measure_30.sh 'code to measure' 'setup code not to measure'
tempfile=$(mktemp)
count=30
for i in $(seq 1 $count); do
eval $2
perf stat -B -e cycles:u $1 2>&1 1>/dev/null | grep cycles:u | awk '{ $1=$1 };1' | cut -d ' ' -f 1 | tr -d , | tee --append $tempfile
done
total=0
for i in $(awk '{ print $1; }' $tempfile); do
unsigned long strnlen(const char *, unsigned long);
void fortify_panic(const char *);
extern inline __attribute__((always_inline, unused))
__attribute__((no_instrument_function)) __attribute__((always_inline))
__attribute__((gnu_inline))
unsigned long
strlen(const char *p)
{
unsigned long ret;
long hweight_long_w;
amd_numa_init_nb, amd_numa_init_base, amd_numa_init_limit;
static hweight_long() {
return __builtin_constant_p(hweight_long_w)
? (hweight_long_w & 1) + hweight_long_w + !(hweight_long_w & 2) +
!(hweight_long_w & 3) + !!(hweight_long_w & 4) +
!!hweight_long_w
<< !(hweight_long_w << 6) +
!(hweight_long_w & 1 << 7 + hweight_long_w) +
!(hweight_long_w >> 1 << hweight_long_w >>
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
index 0bba2add1c92..a491b76e4367 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -371,7 +371,10 @@ public:
}
void changeSection(MCSection *Section, const MCExpr *Subsection) override {
- LastMappingSymbols[getCurrentSection().first] = std::move(LastEMSInfo);
+ llvm::MCSection *Current = getCurrentSection().first;
# $ arm-linux-gnueabi-as -mthumb -march=armv7-a foo.s -o foo.o
# $ clang --target=arm-linux-gnueabi -Wa,-mthumb -Wa,-march=armv7-a -c foo.s
.syntax unified
.globl v7wbi_flush_kern_tlb_range
.align 0
v7wbi_flush_kern_tlb_range:
bx lr
.type v7wbi_flush_kern_tlb_range, %function
+ timeout --foreground 3m unbuffer qemu-system-arm -initrd /android1/boot-utils/images/arm/rootfs.cpio -append 'console=ttyAMA0 earlycon' -machine virt -no-reboot -display none -kernel /android0/kernel-all/arch/arm/boot/zImage -m 512m -nodefaults -serial mon:stdio
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 5.15.0-rc1-00016-g4402e1c6209f (ndesaulniers@ndesaulniers1.mtv.corp.google.com) (Nick Desaulniers clang version 14.0.0 (git@github.com:llvm/llvm-project.git 0a7b8cc5dd8efadeef07bf6e4e93c7df2ebe7220), LLD 14.0.0) #38 SMP Tue Sep 14 17:40:09 PDT 2021
[ 0.000000] CPU: ARMv7 Processor [412fc0f1] revision 1 (ARMv7), cr=50c5387d
[ 0.000000] CPU: div instructions available: patching division code
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[ 0.000000] OF: fdt: Machine model: linux,dummy-virt
[ 0.000000] earlycon: pl11 at MMIO 0x09000000 (options '')
[ 0.000000] printk: bootconsole [pl11] enabled
[ 0.000000] Memory policy: Data