[llvm-commits] CVS: llvm-java/lib/Transforms/StubAdder.cpp Makefile
Alkis Evlogimenos
alkis at cs.uiuc.edu
Mon Feb 7 18:26:44 PST 2005
Changes in directory llvm-java/lib/Transforms:
StubAdder.cpp added (r1.1)
Makefile added (r1.1)
---
Log message:
Remove the hack from compiler that adds stub returns to undefined
functions. Use a pass instead to add stubs after we link a module with
the runtime.
---
Diffs of the changes: (+54 -0)
Makefile | 14 ++++++++++++++
StubAdder.cpp | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
Index: llvm-java/lib/Transforms/StubAdder.cpp
diff -c /dev/null llvm-java/lib/Transforms/StubAdder.cpp:1.1
*** /dev/null Mon Feb 7 20:26:42 2005
--- llvm-java/lib/Transforms/StubAdder.cpp Mon Feb 7 20:26:32 2005
***************
*** 0 ****
--- 1,40 ----
+ //===- Hello.cpp - Example code from "Writing an LLVM Pass" ---------------===//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // This file was developed by the LLVM research group and is distributed under
+ // the University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This file implements two versions of the LLVM "Hello World" pass described
+ // in docs/WritingAnLLVMPass.html
+ //
+ //===----------------------------------------------------------------------===//
+
+ #include "llvm/Pass.h"
+ #include "llvm/Function.h"
+ #include "llvm/Module.h"
+ #include "llvm/Type.h"
+ #include "llvm/Instructions.h"
+ #include "llvm/Constants.h"
+
+ using namespace llvm;
+
+ namespace {
+ // Hello - The first implementation, without getAnalysisUsage.
+ struct StubAdder : public ModulePass {
+ virtual bool runOnModule(Module &M) {
+ for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
+ if (F->empty() && F->getName().find("java") != std::string::npos) {
+ BasicBlock* entry = new BasicBlock("entry", F);
+ if (F->getReturnType() == Type::VoidTy)
+ new ReturnInst(NULL, entry);
+ else
+ new ReturnInst(UndefValue::get(F->getReturnType()), entry);
+ }
+ return true;
+ }
+ };
+ RegisterOpt<StubAdder> X("stubadder", "Stub Adder Pass");
+ }
Index: llvm-java/lib/Transforms/Makefile
diff -c /dev/null llvm-java/lib/Transforms/Makefile:1.1
*** /dev/null Mon Feb 7 20:26:44 2005
--- llvm-java/lib/Transforms/Makefile Mon Feb 7 20:26:32 2005
***************
*** 0 ****
--- 1,14 ----
+ ##===- lib/Transforms/Makefile -----------------------------*- Makefile -*-===##
+ #
+ # The LLVM Compiler Infrastructure
+ #
+ # This file was developed by the LLVM research group and is distributed under
+ # the University of Illinois Open Source License. See LICENSE.TXT for details.
+ #
+ ##===----------------------------------------------------------------------===##
+ LEVEL = ../..
+ LIBRARYNAME = LLVMJavaTransforms
+ SHARED_LIBRARY = 1
+ LOADABLE_MODULE = 1
+
+ include $(LEVEL)/Makefile.common
More information about the llvm-commits
mailing list