diff options
author | Marcin Koscielnicki <koriakin@0x04.net> | 2016-11-21 20:20:39 +0000 |
---|---|---|
committer | Marcin Koscielnicki <koriakin@0x04.net> | 2016-11-21 20:20:39 +0000 |
commit | 6af8e6c3d533c756449366716b63672260fb9279 (patch) | |
tree | 359fd99c8efd27a94978a3cdc2f55b37ac40c7ad /llvm/lib/Analysis/TargetLibraryInfo.cpp | |
parent | 28d5f059ae1ff0e2a8d91f503dc3d9746eafab7a (diff) | |
download | bcm5719-llvm-6af8e6c3d533c756449366716b63672260fb9279.tar.gz bcm5719-llvm-6af8e6c3d533c756449366716b63672260fb9279.zip |
[TLI] Fix breakage introduced by D21739.
The initialize function has an early return for AMDGPU targets. If taken,
the ShouldExtI32* initialization code will not be executed, resulting in
invalid values in the corresponding fields. Fix this by moving the code
to the top of the function.
llvm-svn: 287570
Diffstat (limited to 'llvm/lib/Analysis/TargetLibraryInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/TargetLibraryInfo.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp index ae449f023a4..89470b87259 100644 --- a/llvm/lib/Analysis/TargetLibraryInfo.cpp +++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp @@ -61,6 +61,25 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, }) && "TargetLibraryInfoImpl function names must be sorted"); + bool ShouldExtI32Param = false, ShouldExtI32Return = false, + ShouldSignExtI32Param = false; + // PowerPC64, Sparc64, SystemZ need signext/zeroext on i32 parameters and + // returns corresponding to C-level ints and unsigned ints. + if (T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le || + T.getArch() == Triple::sparcv9 || T.getArch() == Triple::systemz) { + ShouldExtI32Param = true; + ShouldExtI32Return = true; + } + // Mips, on the other hand, needs signext on i32 parameters corresponding + // to both signed and unsigned ints. + if (T.getArch() == Triple::mips || T.getArch() == Triple::mipsel || + T.getArch() == Triple::mips64 || T.getArch() == Triple::mips64el) { + ShouldSignExtI32Param = true; + } + TLI.setShouldExtI32Param(ShouldExtI32Param); + TLI.setShouldExtI32Return(ShouldExtI32Return); + TLI.setShouldSignExtI32Param(ShouldSignExtI32Param); + if (T.getArch() == Triple::r600 || T.getArch() == Triple::amdgcn) { TLI.setUnavailable(LibFunc::ldexp); @@ -414,25 +433,6 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, } TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary); - - bool ShouldExtI32Param = false, ShouldExtI32Return = false, - ShouldSignExtI32Param = false; - // PowerPC64, Sparc64, SystemZ need signext/zeroext on i32 parameters and - // returns corresponding to C-level ints and unsigned ints. - if (T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le || - T.getArch() == Triple::sparcv9 || T.getArch() == Triple::systemz) { - ShouldExtI32Param = true; - ShouldExtI32Return = true; - } - // Mips, on the other hand, needs signext on i32 parameters corresponding - // to both signed and unsigned ints. - if (T.getArch() == Triple::mips || T.getArch() == Triple::mipsel || - T.getArch() == Triple::mips64 || T.getArch() == Triple::mips64el) { - ShouldSignExtI32Param = true; - } - TLI.setShouldExtI32Param(ShouldExtI32Param); - TLI.setShouldExtI32Return(ShouldExtI32Return); - TLI.setShouldSignExtI32Param(ShouldSignExtI32Param); } TargetLibraryInfoImpl::TargetLibraryInfoImpl() { |