[llvm] 356c718 - [AMDGPU] Fix big endian bots after 7c327c2

Nemanja Ivanovic via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 10 11:15:45 PST 2023


Author: Nemanja Ivanovic
Date: 2023-01-10T13:15:37-06:00
New Revision: 356c71830cdf289f32f0bcbcff83cc8870217171

URL: https://github.com/llvm/llvm-project/commit/356c71830cdf289f32f0bcbcff83cc8870217171
DIFF: https://github.com/llvm/llvm-project/commit/356c71830cdf289f32f0bcbcff83cc8870217171.diff

LOG: [AMDGPU] Fix big endian bots after 7c327c2

The pass that this test case is testing has host-endianness
dependencies. This fixes the pertinent one causing failures
on BE bots.

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
index 1a28995f18cb..a28721cc7262 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
@@ -411,19 +411,31 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
             DataExtractor Extractor(S, /*IsLittleEndian=*/true, 8);
             DataExtractor::Cursor Offset(0);
             while (Offset && Offset.tell() < S.size()) {
-              StringRef ReadBytes = Extractor.getBytes(
-                  Offset, std::min(ReadSize, S.size() - Offset.tell()));
+              uint64_t ReadNow = std::min(ReadSize, S.size() - Offset.tell());
+              uint64_t ReadBytes = 0;
+              switch (ReadNow) {
+              default: llvm_unreachable("min(4, X) > 4?");
+              case 1:
+                ReadBytes = Extractor.getU8(Offset);
+                break;
+              case 2:
+                ReadBytes = Extractor.getU16(Offset);
+                break;
+              case 3:
+                ReadBytes = Extractor.getU24(Offset);
+                break;
+              case 4:
+                ReadBytes = Extractor.getU32(Offset);
+                break;
+              }
 
               cantFail(Offset.takeError(),
                        "failed to read bytes from constant array");
 
-              APInt IntVal(8 * ReadBytes.size(), 0);
-              LoadIntFromMemory(
-                  IntVal, reinterpret_cast<const uint8_t *>(ReadBytes.data()),
-                  ReadBytes.size());
+              APInt IntVal(8 * ReadSize, ReadBytes);
 
               // TODO: Should not bothering aligning up.
-              if (ReadBytes.size() < ReadSize)
+              if (ReadNow < ReadSize)
                 IntVal = IntVal.zext(8 * ReadSize);
 
               Type *IntTy = Type::getIntNTy(Ctx, IntVal.getBitWidth());


        


More information about the llvm-commits mailing list