Remove getFunctionAlignment from TargetELFInfo and use new MachineFunction alignment...
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Thu, 2 Jul 2009 02:13:13 +0000 (02:13 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Thu, 2 Jul 2009 02:13:13 +0000 (02:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74686 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetELFWriterInfo.h
lib/CodeGen/ELFCodeEmitter.cpp
lib/Target/TargetELFWriterInfo.cpp
lib/Target/X86/X86ELFWriterInfo.cpp
lib/Target/X86/X86ELFWriterInfo.h

index c1f54d201a0ea6036ddbb8a1748fb5702b6bf034..a5b30c4f6e3d6db8a7f0deed5f78dbeb9ac0a149 100644 (file)
@@ -89,10 +89,6 @@ namespace llvm {
                      : (hasRelocationAddend() ? 12 : 8);
     }
 
-    /// getFunctionAlignment - Returns the alignment for function 'F', targets
-    /// with different alignment constraints should overload this method
-    virtual unsigned getFunctionAlignment(const Function *F) const;
-
     /// getRelocationType - Returns the target specific ELF Relocation type.
     /// 'MachineRelTy' contains the object code independent relocation type
     virtual unsigned getRelocationType(unsigned MachineRelTy) const = 0;
index 168fed56c19600690a3f1fc4bea2419a04e5c859..623507a95897f48ac814a3ef9387f38719d7c881 100644 (file)
@@ -40,10 +40,11 @@ void ELFCodeEmitter::startFunction(MachineFunction &MF) {
   BufferBegin = &BD[0];
   BufferEnd = BufferBegin + BD.capacity();
 
-  // Align the output buffer with function alignment, and
-  // upgrade the section alignment if required
-  unsigned Align =
-    TM.getELFWriterInfo()->getFunctionAlignment(MF.getFunction());
+  // Get the function alignment in bytes
+  unsigned Align = (1 << MF.getAlignment());
+
+  // Align the section size with the function alignment, so the function can
+  // start in a aligned offset, also update the section alignment if needed.
   if (ES->Align < Align) ES->Align = Align;
   ES->Size = (ES->Size + (Align-1)) & (-Align);
 
index 9651e65495e66d678c9ac465ec879c37dc9c0384..3631b3501341858ac7112f932a254a22a94f6312 100644 (file)
@@ -24,13 +24,3 @@ TargetELFWriterInfo::TargetELFWriterInfo(TargetMachine &tm) : TM(tm) {
 
 TargetELFWriterInfo::~TargetELFWriterInfo() {}
 
-/// getFunctionAlignment - Returns the alignment for function 'F', targets
-/// with different alignment constraints should overload this method
-unsigned TargetELFWriterInfo::getFunctionAlignment(const Function *F) const {
-  const TargetData *TD = TM.getTargetData();
-  unsigned FnAlign = F->getAlignment();
-  unsigned TDAlign = TD->getPointerABIAlignment();
-  unsigned Align = std::max(FnAlign, TDAlign);
-  assert(!(Align & (Align-1)) && "Alignment is not a power of two!");
-  return Align;
-}
index 315118f61091c255a48b6ea501b770dd2a2074d8..912ab0e886f4d8539567eb918e94ae05f7ec2cb6 100644 (file)
@@ -59,18 +59,6 @@ unsigned X86ELFWriterInfo::getRelocationType(unsigned MachineRelTy) const {
   return 0;
 }
 
-unsigned X86ELFWriterInfo::getFunctionAlignment(const Function *F) const {
-  unsigned FnAlign = 4;
-
-  if (F->hasFnAttr(Attribute::OptimizeForSize))
-    FnAlign = 1;
-
-  if (F->getAlignment())
-    FnAlign = Log2_32(F->getAlignment());
-
-  return (1 << FnAlign);
-}
-
 long int X86ELFWriterInfo::getAddendForRelTy(unsigned RelTy) const {
   if (is64Bit) {
     switch(RelTy) {
index 96485b8970714ced36f304dbab0cfdc26f66182c..2ba1a0bd70a23c5cf17ee4598a6fe89cf3ae9ad4 100644 (file)
@@ -41,10 +41,6 @@ namespace llvm {
     X86ELFWriterInfo(TargetMachine &TM);
     virtual ~X86ELFWriterInfo();
 
-    /// getFunctionAlignment - Returns the alignment for function 'F', targets
-    /// with different alignment constraints should overload this method
-    virtual unsigned getFunctionAlignment(const Function *F) const;
-
     /// getRelocationType - Returns the target specific ELF Relocation type.
     /// 'MachineRelTy' contains the object code independent relocation type
     virtual unsigned getRelocationType(unsigned MachineRelTy) const;