#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
+#include "llvm/InlineAsm.h"
#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
#include <functional>
-
using namespace llvm;
#if 0
-#include <iostream>
-#define SC_DEBUG(X) std::cerr << X
+#include "llvm/Support/Streams.h"
+#define SC_DEBUG(X) llvm_cerr << X
#else
#define SC_DEBUG(X)
#endif
SC_DEBUG("Inserting function constants:\n");
for (Module::const_iterator F = TheModule->begin(), E = TheModule->end();
F != E; ++F) {
- for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I){
- for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op)
- if (isa<Constant>(I->getOperand(op)) &&
- !isa<GlobalValue>(I->getOperand(op)))
- getOrCreateSlot(I->getOperand(op));
+ for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
+ for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
+ OI != E; ++OI) {
+ if ((isa<Constant>(*OI) && !isa<GlobalValue>(*OI)) ||
+ isa<InlineAsm>(*OI))
+ getOrCreateSlot(*OI);
+ }
getOrCreateSlot(I->getType());
- if (const VANextInst *VAN = dyn_cast<VANextInst>(&*I))
- getOrCreateSlot(VAN->getArgType());
}
processSymbolTableConstants(&F->getSymbolTable());
}
SC_DEBUG("begin processFunction!\n");
// If we emitted all of the function constants, build a compaction table.
- if ( ModuleContainsAllFunctionConstants)
+ if (ModuleContainsAllFunctionConstants)
buildCompactionTable(F);
// Update the ModuleLevel entries to be accurate.
for(Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
getOrCreateSlot(I);
- if ( !ModuleContainsAllFunctionConstants ) {
+ if (!ModuleContainsAllFunctionConstants) {
// Iterate over all of the instructions in the function, looking for
// constant values that are referenced. Add these to the value pools
// before any nonconstant values. This will be turned into the constant
// Emit all of the constants that are being used by the instructions in
// the function...
- constant_iterator CI = constant_begin(F);
- constant_iterator CE = constant_end(F);
- while ( CI != CE ) {
- this->getOrCreateSlot(*CI);
- ++CI;
- }
+ for (constant_iterator CI = constant_begin(F), CE = constant_end(F);
+ CI != CE; ++CI)
+ getOrCreateSlot(*CI);
// If there is a symbol table, it is possible that the user has names for
// constants that are not being used. In this case, we will have problems
getOrCreateSlot(BB);
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) {
getOrCreateSlot(I);
- if (const VANextInst *VAN = dyn_cast<VANextInst>(I))
- getOrCreateSlot(VAN->getArgType());
}
}
for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
getOrCreateCompactionTableSlot(I->getType());
for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op)
- if (isa<Constant>(I->getOperand(op)))
+ if (isa<Constant>(I->getOperand(op)) || isa<InlineAsm>(I->getOperand(op)))
getOrCreateCompactionTableSlot(I->getOperand(op));
- if (const VANextInst *VAN = dyn_cast<VANextInst>(&*I))
- getOrCreateCompactionTableSlot(VAN->getArgType());
}
// Do the types in the symbol table
// Used for debugging DefSlot=-1 assertion...
//if (Typ == Type::TypeTy)
- // cerr << "Inserting type '" << cast<Type>(D)->getDescription() << "'!\n";
+ // llvm_cerr << "Inserting type '"<<cast<Type>(D)->getDescription() <<"'!\n";
if (Typ->isDerivedType()) {
int ValSlot;
return (int)DestSlot;
}
-// vim: sw=2 ai