#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Support/DataTypes.h"
+#include <set>
namespace llvm {
class Constant;
///
unsigned FunctionNumber;
+ protected:
+ // Necessary for external weak linkage support
+ std::set<const GlobalValue*> ExtWeakSymbols;
+
public:
/// Output stream on which we're printing assembly code.
///
}
bool AsmPrinter::doFinalization(Module &M) {
+ if (TAI->getWeakRefDirective()) {
+ if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
+ SwitchToDataSection("");
+
+ for (std::set<const GlobalValue*>::iterator i = ExtWeakSymbols.begin(),
+ e = ExtWeakSymbols.end(); i != e; ++i) {
+ const GlobalValue *GV = *i;
+ std::string Name = Mang->getValueName(GV);
+ O << TAI->getWeakRefDirective() << Name << "\n";
+ }
+ }
+
delete Mang; Mang = 0;
return false;
}
: AsmPrinter(O, TM, T) {
}
- std::set<std::string> ExtWeakSymbols;
-
/// We name each basic block in a Function with a unique number, so
/// that we can consistently refer to them later. This is cleared
/// at the beginning of each call to runOnMachineFunction().
std::string Name = Mang->getValueName(GV);
O << Name;
if (GV->hasExternalWeakLinkage()) {
- ExtWeakSymbols.insert(Name);
+ ExtWeakSymbols.insert(GV);
}
}
break;
}
}
- if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
- SwitchToDataSection("");
- for (std::set<std::string>::iterator i = ExtWeakSymbols.begin(),
- e = ExtWeakSymbols.end(); i != e; ++i) {
- O << TAI->getWeakRefDirective() << *i << "\n";
- }
-
AsmPrinter::doFinalization(M);
return false; // success
}
struct VISIBILITY_HIDDEN PPCAsmPrinter : public AsmPrinter {
std::set<std::string> FnStubs, GVStubs;
const PPCSubtarget &Subtarget;
-
- // Necessary for external weak linkage support
- std::set<std::string> ExtWeakSymbols;
PPCAsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
: AsmPrinter(O, TM, T), Subtarget(TM.getSubtarget<PPCSubtarget>()) {
FnStubs.insert(Name);
O << "L" << Name << "$stub";
if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(Name);
+ ExtWeakSymbols.insert(GV);
return;
}
}
O << Name;
if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(Name);
+ ExtWeakSymbols.insert(GV);
return;
}
// reference!
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(Mang->getValueName(GV));
+ ExtWeakSymbols.insert(GV);
EmitGlobalConstant(C);
O << '\n';
}
}
- if (TAI->getWeakRefDirective()) {
- if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
- SwitchToDataSection("");
- for (std::set<std::string>::iterator i = ExtWeakSymbols.begin(),
- e = ExtWeakSymbols.end(); i != e; ++i) {
- O << TAI->getWeakRefDirective() << *i << "\n";
- }
- }
-
bool isPPC64 = TD->getPointerSizeInBits() == 64;
// Output stubs for dynamically-linked functions
}
if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(Name);
+ ExtWeakSymbols.insert(GV);
int Offset = MO.getOffset();
if (Offset > 0)
// reference!
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(Mang->getValueName(GV));
+ ExtWeakSymbols.insert(GV);
EmitGlobalConstant(C);
O << '\n';
O << "\t.ascii \" -export:" << *i << "\"\n";
}
- if (TAI->getWeakRefDirective()) {
- if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
- SwitchToDataSection("");
- for (std::set<std::string>::iterator i = ExtWeakSymbols.begin(),
- e = ExtWeakSymbols.end(); i != e; ++i) {
- O << TAI->getWeakRefDirective() << *i << "\n";
- }
- }
-
if (Subtarget->isTargetDarwin()) {
SwitchToDataSection("");
// Necessary for dllexport support
std::set<std::string> DLLExportedFns, DLLExportedGVs;
- // Necessary for external weak linkage support
- std::set<std::string> ExtWeakSymbols;
-
inline static bool isScale(const MachineOperand &MO) {
return MO.isImmediate() &&
(MO.getImmedValue() == 1 || MO.getImmedValue() == 2 ||