Commit 30c691d4 authored by Marius Wachtler's avatar Marius Wachtler

Some small changes to simplify the generated IR.

+ mark the alloc routines as no alias (=attribute(malloc)).
  This marks every alloc call as noalias in the IR.
  (While I felt somewhat frightened by the malloc attribute AFAIK the generated IR looks reasonable.)
+ inline the trivial Box constructor
+ fix dead allocs pass: we will now remove the useless list creation inside f2 in speculation_test.py
parent 89d0615c
......@@ -18,6 +18,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/PostDominators.h"
......@@ -402,11 +403,12 @@ private:
std::unordered_map<BasicBlock*, Value*> seen;
Value* new_v = getLoadValFromPrevious(li->getPointerOperand(), li->getParent(), seen, chain);
assert(new_v);
if (!new_v) {
new_v = llvm::UndefValue::get(li->getType());
}
if (VERBOSITY("opt") >= 1)
errs() << "Remapped to: " << *new_v << '\n';
li->replaceAllUsesWith(new_v);
li->eraseFromParent();
llvm::replaceAndRecursivelySimplify(li, new_v);
}
public:
......
......@@ -398,7 +398,19 @@ public:
llvm::iterator_range<BoxIterator> pyElements();
Box(BoxedClass* cls);
Box(BoxedClass* cls) : cls(cls) {
// if (TRACK_ALLOCATIONS) {
// int id = Stats::getStatId("allocated_" + *getNameOfClass(c));
// Stats::log(id);
//}
// the only way cls should be NULL is if we're creating the type_cls
// object itself:
if (cls == NULL) {
ASSERT(type_cls == NULL, "should pass a non-null cls here");
} else {
}
}
HCAttrs* getAttrsPtr();
......
......@@ -108,8 +108,8 @@ private:
Block* full_heads[NUM_BUCKETS];
LargeObj* large_head = NULL;
GCAllocation* allocSmall(size_t rounded_size, int bucket_idx);
GCAllocation* allocLarge(size_t bytes);
GCAllocation* __attribute__((__malloc__)) allocSmall(size_t rounded_size, int bucket_idx);
GCAllocation* __attribute__((__malloc__)) allocLarge(size_t bytes);
// DS_DEFINE_MUTEX(lock);
DS_DEFINE_SPINLOCK(lock);
......@@ -134,7 +134,7 @@ public:
GCAllocation* realloc(GCAllocation* alloc, size_t bytes);
GCAllocation* alloc(size_t bytes) {
GCAllocation* __attribute__((__malloc__)) alloc(size_t bytes) {
GCAllocation* rtn;
// assert(bytes >= 16);
if (bytes <= 16)
......
......@@ -494,21 +494,6 @@ HiddenClass* HiddenClass::delAttrToMakeHC(const std::string& attr) {
return cur;
}
Box::Box(BoxedClass* cls) : cls(cls) {
// if (TRACK_ALLOCATIONS) {
// int id = Stats::getStatId("allocated_" + *getNameOfClass(c));
// Stats::log(id);
//}
// the only way cls should be NULL is if we're creating the type_cls
// object itself:
if (cls == NULL) {
ASSERT(type_cls == NULL, "should pass a non-null cls here");
} else {
}
}
HCAttrs* Box::getAttrsPtr() {
assert(cls->instancesHaveAttrs());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment