[llvm-commits] [llvm] r147431 - in /llvm/trunk/unittests: Bitcode/ Bitcode/BitReaderTest.cpp Bitcode/Makefile CMakeLists.txt Makefile VMCore/Makefile VMCore/pr11677.cpp
Chandler Carruth
chandlerc at gmail.com
Mon Jan 2 01:19:48 PST 2012
Author: chandlerc
Date: Mon Jan 2 03:19:48 2012
New Revision: 147431
URL: http://llvm.org/viewvc/llvm-project?rev=147431&view=rev
Log:
Undo the hack in r147427 and move this unittest to a better home. This
is testing the bitcode reader's functionality, not VMCore's. Add the
what is a hope sufficient build system mojo to build and run a new
unittest.
Also clean up some of the test's naming. The goal for the file should be
to unittest the Bitcode Reader, and this is just one particular test
among potentially many in the future. Also, reverse my position and
relegate the PR# to a comment, but stash the comment on the same line as
the test name so it doesn't get lost. This makes the code more
self-documenting hopefully w/o losing track of the PR number.
Added:
llvm/trunk/unittests/Bitcode/
llvm/trunk/unittests/Bitcode/BitReaderTest.cpp
- copied, changed from r147427, llvm/trunk/unittests/VMCore/pr11677.cpp
llvm/trunk/unittests/Bitcode/Makefile
- copied, changed from r147427, llvm/trunk/unittests/VMCore/Makefile
Removed:
llvm/trunk/unittests/VMCore/pr11677.cpp
Modified:
llvm/trunk/unittests/CMakeLists.txt
llvm/trunk/unittests/Makefile
llvm/trunk/unittests/VMCore/Makefile
Copied: llvm/trunk/unittests/Bitcode/BitReaderTest.cpp (from r147427, llvm/trunk/unittests/VMCore/pr11677.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Bitcode/BitReaderTest.cpp?p2=llvm/trunk/unittests/Bitcode/BitReaderTest.cpp&p1=llvm/trunk/unittests/VMCore/pr11677.cpp&r1=147427&r2=147431&rev=147431&view=diff
==============================================================================
--- llvm/trunk/unittests/VMCore/pr11677.cpp (original)
+++ llvm/trunk/unittests/Bitcode/BitReaderTest.cpp Mon Jan 2 03:19:48 2012
@@ -1,4 +1,4 @@
-//===- llvm/unittest/VMCore/pr11677.cpp - Test for blockaddr --------------===//
+//===- llvm/unittest/Bitcode/BitReaderTest.cpp - Tests for BitReader ------===//
//
// The LLVM Compiler Infrastructure
//
@@ -49,7 +49,7 @@
WriteBitcodeToStream(Mod, Stream);
}
-TEST(PR11677, BlockAddr) {
+TEST(BitReaderTest, MaterializeFunctionsForBlockAddr) { // PR11677
std::vector<unsigned char> Mem;
writeModuleToBuffer(Mem);
StringRef Data((const char*)&Mem[0], Mem.size());
@@ -60,5 +60,6 @@
passes.add(createVerifierPass());
passes.run(*m);
}
+
}
}
Copied: llvm/trunk/unittests/Bitcode/Makefile (from r147427, llvm/trunk/unittests/VMCore/Makefile)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Bitcode/Makefile?p2=llvm/trunk/unittests/Bitcode/Makefile&p1=llvm/trunk/unittests/VMCore/Makefile&r1=147427&r2=147431&rev=147431&view=diff
==============================================================================
--- llvm/trunk/unittests/VMCore/Makefile (original)
+++ llvm/trunk/unittests/Bitcode/Makefile Mon Jan 2 03:19:48 2012
@@ -1,4 +1,4 @@
-##===- unittests/VMCore/Makefile ---------------------------*- Makefile -*-===##
+##===- unittests/Bitcode/Makefile --------------------------*- Makefile -*-===##
#
# The LLVM Compiler Infrastructure
#
@@ -8,8 +8,8 @@
##===----------------------------------------------------------------------===##
LEVEL = ../..
-TESTNAME = VMCore
-LINK_COMPONENTS := core support bitreader bitwriter target ipa
+TESTNAME = Bitcode
+LINK_COMPONENTS := core support bitreader bitwriter
include $(LEVEL)/Makefile.config
include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
Modified: llvm/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CMakeLists.txt?rev=147431&r1=147430&r2=147431&view=diff
==============================================================================
--- llvm/trunk/unittests/CMakeLists.txt (original)
+++ llvm/trunk/unittests/CMakeLists.txt Mon Jan 2 03:19:48 2012
@@ -112,7 +112,6 @@
VMCore/PassManagerTest.cpp
VMCore/ValueMapTest.cpp
VMCore/VerifierTest.cpp
- VMCore/pr11677.cpp
)
# MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
@@ -123,6 +122,10 @@
add_llvm_unittest(VMCore ${VMCoreSources})
+add_llvm_unittest(Bitcode
+ Bitcode/BitReaderTest.cpp
+ )
+
set(LLVM_LINK_COMPONENTS
Support
Core
Modified: llvm/trunk/unittests/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Makefile?rev=147431&r1=147430&r2=147431&view=diff
==============================================================================
--- llvm/trunk/unittests/Makefile (original)
+++ llvm/trunk/unittests/Makefile Mon Jan 2 03:19:48 2012
@@ -9,7 +9,7 @@
LEVEL = ..
-PARALLEL_DIRS = ADT ExecutionEngine Support Transforms VMCore Analysis
+PARALLEL_DIRS = ADT ExecutionEngine Support Transforms VMCore Analysis Bitcode
include $(LEVEL)/Makefile.common
Modified: llvm/trunk/unittests/VMCore/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/Makefile?rev=147431&r1=147430&r2=147431&view=diff
==============================================================================
--- llvm/trunk/unittests/VMCore/Makefile (original)
+++ llvm/trunk/unittests/VMCore/Makefile Mon Jan 2 03:19:48 2012
@@ -9,7 +9,7 @@
LEVEL = ../..
TESTNAME = VMCore
-LINK_COMPONENTS := core support bitreader bitwriter target ipa
+LINK_COMPONENTS := core support target ipa
include $(LEVEL)/Makefile.config
include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
Removed: llvm/trunk/unittests/VMCore/pr11677.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/pr11677.cpp?rev=147430&view=auto
==============================================================================
--- llvm/trunk/unittests/VMCore/pr11677.cpp (original)
+++ llvm/trunk/unittests/VMCore/pr11677.cpp (removed)
@@ -1,64 +0,0 @@
-//===- llvm/unittest/VMCore/pr11677.cpp - Test for blockaddr --------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/Bitcode/BitstreamWriter.h"
-#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/Constants.h"
-#include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Module.h"
-#include "llvm/PassManager.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "gtest/gtest.h"
-
-namespace llvm {
-namespace {
-
-static Module *makeLLVMModule() {
- Module* Mod = new Module("test-mem", getGlobalContext());
-
- FunctionType* FuncTy =
- FunctionType::get(Type::getVoidTy(Mod->getContext()), false);
- Function* Func = Function::Create(FuncTy,GlobalValue::ExternalLinkage,
- "func", Mod);
-
- BasicBlock* Entry = BasicBlock::Create(Mod->getContext(), "entry", Func);
- new UnreachableInst(Mod->getContext(), Entry);
-
- BasicBlock* BB = BasicBlock::Create(Mod->getContext(), "bb", Func);
- new UnreachableInst(Mod->getContext(), BB);
-
- PointerType* Int8Ptr = Type::getInt8PtrTy(Mod->getContext());
- new GlobalVariable(*Mod, Int8Ptr, /*isConstant=*/true,
- GlobalValue::ExternalLinkage,
- BlockAddress::get(BB), "table");
-
- return Mod;
-}
-
-static void writeModuleToBuffer(std::vector<unsigned char> &Buffer) {
- Module *Mod = makeLLVMModule();
- BitstreamWriter Stream(Buffer);
- WriteBitcodeToStream(Mod, Stream);
-}
-
-TEST(PR11677, BlockAddr) {
- std::vector<unsigned char> Mem;
- writeModuleToBuffer(Mem);
- StringRef Data((const char*)&Mem[0], Mem.size());
- MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(Data, "test", false);
- std::string errMsg;
- Module *m = getLazyBitcodeModule(Buffer, getGlobalContext(), &errMsg);
- PassManager passes;
- passes.add(createVerifierPass());
- passes.run(*m);
-}
-}
-}
More information about the llvm-commits
mailing list