//===----------------------------------------------------------------------===//
#include "llvm/Constants.h"
+#include "llvm/DerivedTypes.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Function.h"
#include "llvm/Module.h"
COMMDirective = "\t.comm\t";
COMMDirectiveTakesAlignment = true;
HasDotTypeDotSizeDirective = true;
+ HasSingleParameterDotFile = true;
UsedDirective = 0;
WeakRefDirective = 0;
WeakDefDirective = 0;
SupportsDebugInformation = false;
SupportsExceptionHandling = false;
DwarfRequiresFrameSection = true;
+ SupportsMacInfoSection = true;
+ NonLocalEHFrameLabel = false;
GlobalEHDirective = 0;
SupportsWeakOmittedEHFrame = true;
DwarfSectionOffsetDirective = 0;
DataSection = getUnnamedSection("\t.data", SectionFlags::Writeable);
}
-TargetAsmInfo::TargetAsmInfo() {
- fillDefaultValues();
-}
-
-TargetAsmInfo::TargetAsmInfo(const TargetMachine &TM) {
+TargetAsmInfo::TargetAsmInfo(const TargetMachine &tm)
+ : TM(tm) {
fillDefaultValues();
}
return (C->isNullValue() && !GV->isConstant() && !NoZerosInBSS);
}
+static bool isConstantString(const Constant *C) {
+ // First check: is we have constant array of i8 terminated with zero
+ const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
+ // Check, if initializer is a null-terminated string
+ if (CVA && CVA->isCString())
+ return true;
+
+ // Another possibility: [1 x i8] zeroinitializer
+ if (isa<ConstantAggregateZero>(C)) {
+ if (const ArrayType *Ty = dyn_cast<ArrayType>(C->getType())) {
+ return (Ty->getElementType() == Type::Int8Ty &&
+ Ty->getNumElements() == 1);
+ }
+ }
+
+ return false;
+}
+
+
SectionKind::Kind
TargetAsmInfo::SectionKindForGlobal(const GlobalValue *GV) const {
// Early exit - functions should be always in text sections.
if (C->ContainsRelocations())
return SectionKind::ROData;
else {
- const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
// Check, if initializer is a null-terminated string
- if (CVA && CVA->isCString())
+ if (isConstantString(C))
return SectionKind::RODataMergeStr;
else
return SectionKind::RODataMergeConst;
default:
assert(0 && "Unknown section kind");
}
+ return NULL;
}
const Section*