Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 1356:59c2aa9def23

Show
Ignore:
Timestamp:
05/15/09 11:05:35 (3 years ago)
Author:
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
branch:
default
Message:

Enabled fix for ticket #294 . It will try it's best to let LLVM handle the alignment, and fall back to manual padding when that's not possible. If this causes problems again, we'll have to consistently pad manually using packed structs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gen/llvmhelpers.cpp

    r1355 r1356  
    14521452        return alignedoffset; 
    14531453 
    1454     // disabled since this can fail for opaques. if the check above is not in plac
    1455     // it does so for gcx.d!!! 
    1456     // this needs to be investigated, but I don't have time right now! 
    1457 #if 0 
    1458     // if not, we have to make sure it agrees with what llvm thinks is the alignment 
    1459     // sometimes this is different from what we really need (in case of unions, see #294) 
    1460     // so if there we get different results we don't realign the offset at all and instead 
    1461     // just return the original offset, and rely on the users to insert padding manually. 
    1462     IF_LOG Logger::cout() << "getting alignment for type " << type->toChars() 
    1463         << " with llvm type " << *DtoType(type) << std::endl
    1464     size_t alignsize2 = gTargetData->getABITypeAlignment(DtoType(type)); 
    1465  
     1454    // we cannot get the llvm alignment if the type is still opaque, this can happen in som
     1455    // forward reference situations, so when this happens we fall back to manual padding. 
     1456    const llvm::Type* T = DtoType(type); 
     1457    if (llvm::isa<llvm::OpaqueType>(T)) 
     1458    { 
     1459        return offset; 
     1460    } 
     1461 
     1462    // then we check against the llvm alignment 
     1463    size_t alignsize2 = gTargetData->getABITypeAlignment(T)
     1464 
     1465    // if it differs we need to insert manual padding as well 
    14661466    if (alignsize != alignsize2) 
    14671467    { 
    14681468        assert(alignsize > alignsize2 && "this is not good, the D and LLVM " 
    14691469            "type alignments differ, but LLVM's is bigger! This will break " 
    1470             "the type mapping algorithms"); 
     1470            "aggregate type mapping"); 
    14711471        // don't try and align the offset, and let the mappers pad 100% manually 
    14721472        return offset; 
    14731473    } 
    1474 #endif 
    1475  
     1474 
     1475    // ok, we're good, llvm will align properly! 
    14761476    return alignedoffset; 
    14771477} 
Copyright © 2008, LDC Development Team.