diff options
| author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-07-02 02:13:13 +0000 |
|---|---|---|
| committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-07-02 02:13:13 +0000 |
| commit | eefbf1961c10a0d29408d8cab59e3af96d7b2d11 (patch) | |
| tree | 83fb56ebb61c2ad383cbed49a02e1208ebf171a7 | |
| parent | 9bff6531fd344adc7b3ab441aadadbfb3c8c6e7e (diff) | |
| download | bcm5719-llvm-eefbf1961c10a0d29408d8cab59e3af96d7b2d11.tar.gz bcm5719-llvm-eefbf1961c10a0d29408d8cab59e3af96d7b2d11.zip | |
Remove getFunctionAlignment from TargetELFInfo and use new MachineFunction alignment method
llvm-svn: 74686
| -rw-r--r-- | llvm/include/llvm/Target/TargetELFWriterInfo.h | 4 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/ELFCodeEmitter.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/Target/TargetELFWriterInfo.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86ELFWriterInfo.cpp | 12 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86ELFWriterInfo.h | 4 |
5 files changed, 5 insertions, 34 deletions
diff --git a/llvm/include/llvm/Target/TargetELFWriterInfo.h b/llvm/include/llvm/Target/TargetELFWriterInfo.h index c1f54d201a0..a5b30c4f6e3 100644 --- a/llvm/include/llvm/Target/TargetELFWriterInfo.h +++ b/llvm/include/llvm/Target/TargetELFWriterInfo.h @@ -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; diff --git a/llvm/lib/CodeGen/ELFCodeEmitter.cpp b/llvm/lib/CodeGen/ELFCodeEmitter.cpp index 168fed56c19..623507a9589 100644 --- a/llvm/lib/CodeGen/ELFCodeEmitter.cpp +++ b/llvm/lib/CodeGen/ELFCodeEmitter.cpp @@ -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); diff --git a/llvm/lib/Target/TargetELFWriterInfo.cpp b/llvm/lib/Target/TargetELFWriterInfo.cpp index 9651e65495e..3631b350134 100644 --- a/llvm/lib/Target/TargetELFWriterInfo.cpp +++ b/llvm/lib/Target/TargetELFWriterInfo.cpp @@ -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; -} diff --git a/llvm/lib/Target/X86/X86ELFWriterInfo.cpp b/llvm/lib/Target/X86/X86ELFWriterInfo.cpp index 315118f6109..912ab0e886f 100644 --- a/llvm/lib/Target/X86/X86ELFWriterInfo.cpp +++ b/llvm/lib/Target/X86/X86ELFWriterInfo.cpp @@ -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) { diff --git a/llvm/lib/Target/X86/X86ELFWriterInfo.h b/llvm/lib/Target/X86/X86ELFWriterInfo.h index 96485b89707..2ba1a0bd70a 100644 --- a/llvm/lib/Target/X86/X86ELFWriterInfo.h +++ b/llvm/lib/Target/X86/X86ELFWriterInfo.h @@ -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; |

