//===- CodeGeneratorBug.cpp - Debug code generation bugs ------------------===//
+//
+// 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 program code generation debugging support.
//
// Use the function we just added to get addresses of functions we need
// Iterate over the global declarations in the Safe module
for (Module::iterator F=SafeModule->begin(),E=SafeModule->end(); F!=E; ++F){
- if (F->isExternal() && !F->use_empty() && &(*F) != resolverFunc &&
- F->getIntrinsicID() == 0 /* ignore intrinsics */) {
+ if (F->isExternal() && !F->use_empty() && &*F != resolverFunc &&
+ F->getIntrinsicID() == 0 /* ignore intrinsics */ &&
+ // Don't forward functions which are external in the test module too.
+ !TestModule->getNamedFunction(F->getName())->isExternal()) {
// If it has a non-zero use list,
// 1. Add a string constant with its name to the global file
// The correct type is `const [ NUM x sbyte ]' where NUM is length of
ResolverArgs.push_back(GEP);
// Insert code at the beginning of the function
- for (Value::use_iterator i=F->use_begin(), e=F->use_end(); i!=e; ++i) {
- if (Instruction* Inst = dyn_cast<Instruction>(*i)) {
+ while (!F->use_empty())
+ if (Instruction *Inst = dyn_cast<Instruction>(F->use_back())) {
// call resolver(GetElementPtr...)
CallInst *resolve = new CallInst(resolverFunc, ResolverArgs,
"resolver", Inst);
std::cerr << "Non-instruction is using an external function!\n";
abort();
}
- }
}
}
}
} else {
std::cout << " llc " << TestModuleBC << " -o " << TestModuleBC << ".s\n";
std::cout << " gcc " << SharedObject << " " << TestModuleBC
- << ".s -o " << TestModuleBC << ".exe\n";
+ << ".s -o " << TestModuleBC << ".exe -Wl,-R.\n";
std::cout << " " << TestModuleBC << ".exe";
}
for (unsigned i=0, e = InputArgv.size(); i != e; ++i)
#else
<< " -shared" // `-shared' for Linux/X86, maybe others
#endif
- << "\n";
+ << " -fno-strict-aliasing\n";
} else {
removeFile(TestModuleBC);
removeFile(SafeModuleBC);