Skip to content

Instantly share code, notes, and snippets.

View bploeckelman's full-sized avatar

Brian Ploeckelman bploeckelman

View GitHub Profile
@bploeckelman
bploeckelman / gdx-lwjgl-gl4.6-example.java
Last active December 14, 2022 00:42
Example use of LWGL in a LibGDX application to access OpenGL 4.6 features
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
/**
Launches the desktop (LWJGL3) application.
** Need to configure the OpenGL version here **
*/
public class Lwjgl3Launcher {
public static void main(String[] args) {
createApplication();
@bploeckelman
bploeckelman / keybase.md
Last active August 2, 2016 17:38
keybase.io proof

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@bploeckelman
bploeckelman / count-bb.cpp
Created September 3, 2012 23:31
Ex2. Dynamic BasicBlock Count
bool CountBasicBlocks::runOnBasicBlock(BasicBlock &BB, Module &M) {
// Get the bbCounter GlobalVariable
GlobalVariable *bbCounter = M.getGlobalVariable("bbCounter");
assert(bbCounter && "Error: unable to get BasicBlock counter");
// Insert instructions at the end of this BasicBlock
TerminatorInst *InsertPos = BB.getTerminator();
// Load, increment and store the value back
Value *OldVal = new LoadInst(bbCounter, "old.bb.count", InsertPos);
@bploeckelman
bploeckelman / count-bb.cpp
Created September 3, 2012 23:17
Ex2. Dynamic BasicBlock Count
bool CountBasicBlocks::initialize(Module &M) {
Function *Main = M.getFunction("main");
assert(Main && "Error: count-bb requires a main function");
Type *I64Ty = Type::getInt64Ty(M.getContext());
// Create and insert a new GlobalVariable to track the number
// of basic blocks that are executed during the program's run
// int64 bbCounter = 0;
new GlobalVariable(
@bploeckelman
bploeckelman / fib.c
Created September 3, 2012 23:03
Ex2. Dynamic BasicBlock Count - test program 2
#include <stdio.h>
int fib(int x)
{
if (x < 0 ) return 0;
if (x == 0 || x == 1)
return x;
else
return fib(x - 1) + fib(x - 2);
@bploeckelman
bploeckelman / hello.c
Created September 3, 2012 23:03
Ex2. Dynamic BasicBlock Count - test program 1
#include <stdio.h>
int main()
{
printf("Hello llvm\n");
return 0;
}
@bploeckelman
bploeckelman / exithandler.c
Created September 3, 2012 22:57
Ex2. Dynamic BasicBlock Count - atexit handler
#include <stdio.h>
#include <stdlib.h>
extern int bbCounter;
void exitfunc()
{
printf("NUMBER OF BASIC BLOCKS EXECUTED := %d\n", bbCounter);
}
@bploeckelman
bploeckelman / count-bb.cpp
Created September 3, 2012 22:47
Ex1. Dynamic BasicBlock Count LLVM Opt ModulePass
//===- count-bb.cpp - Counts number of executed basic-blocks -------------===//
//
// This file implements an LLVM pass that counts the number of BasicBlocks
// that are executed by a program outputs the total count of executed
// BasicBlocks when the program terminates by using a separately defined
// function that is called atexit.
//
//===---------------------------------------------------------------------===//
#define DEBUG_TYPE "count-bb"
@bploeckelman
bploeckelman / simple-stats.cpp
Created August 30, 2012 21:37
Ex1. Simple Statistics for LLVM Opt
#define DEBUG_TYPE "simple-stats"
#include "llvm/Pass.h"
#include "llvm/Module.h"
#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "llvm/ADT/Statistic.h"
STATISTIC(NumFunctions, "Number of functions in module");
STATISTIC(NumBasicBlocks, "Number of basic blocks in module");