[LLVMbugs] [Bug 8364] New: Verifier doesn't flag out-of-module constants, BC writing crashes
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Oct 12 11:58:13 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=8364
Summary: Verifier doesn't flag out-of-module constants, BC
writing crashes
Product: libraries
Version: 2.7
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Core LLVM classes
AssignedTo: unassignedbugs at nondot.org
ReportedBy: clemahieu at gmail.com
CC: llvmbugs at cs.uiuc.edu
BitCode generation fails with "Unknown constant!" "UNREACHABLE executed at
BitcodeWriter.cpp:895
Issue can be reproduced with the following:
llvm::LLVMContext ctx;
llvm::StringRef mn1 ("m1");
llvm::StringRef mn2 ("m2");
llvm::Module m1 (mn1, ctx);
llvm::Module m2 (mn2, ctx);
const llvm::Type * rt = llvm::Type::getVoidTy (ctx);
const llvm::FunctionType * ft = llvm::FunctionType::get (rt, false);
llvm::Function * f1 = llvm::Function::Create (ft,
llvm::GlobalValue::ExternalLinkage);
m1.getFunctionList ().push_back (f1);
const llvm::IntegerType * it = llvm::IntegerType::get (ctx, 8);
const llvm::PointerType * pt = llvm::PointerType::get (it, 0);
const llvm::Constant * ce = llvm::ConstantExpr::getBitCast (f1, pt);
llvm::Constant * v [1] = {(llvm::Constant *)ce};
const llvm::ArrayType * at = llvm::ArrayType::get (pt, 1);
const llvm::Constant * a = llvm::ConstantArray::get (at, v, 1);
const llvm::Type * gt = a->getRawType ();
llvm::GlobalVariable * g = new llvm::GlobalVariable (gt, true,
llvm::GlobalValue::ExternalLinkage, (llvm::Constant *)a);
m2.getGlobalList ().push_back (g);
std::string message;
bool result = llvm::verifyModule (m2, llvm::ReturnStatusAction, &message);
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list