[llvm-branch-commits] [clang] a619e46 - [clang][Driver] Prefer non-Linux emulations for baremetal Arm/AArch64 targets (#149235)
Author: Jonathon Penix
Date: 2025-08-12T10:44:02+02:00
New Revision: a619e46315156326fdd5e2dfb16558d77216eef0
URL:
https://github.com/llvm/llvm-project/commit/a619e46315156326fdd5e2dfb16558d77216eef0
DIFF:
https://github.com/llvm/llvm-project/commit/a619e46315156326fdd5e2dfb16558d77216eef0.diff
LOG: [clang][Driver] Prefer non-Linux emulations for baremetal Arm/AArch64
targets (#149235)
I'm unsure if there is an official source for which targets use/support
which emulations, but for the baremetal GNU Arm/AArch64 toolchains or
binutils builds I've tried to use, GNU ld either did not support the
Linux emulations (resulting in errors unless overriding the emulation)
or the Linux emulations were supported but GCC passed the non-Linux
emulations by default.
These emulations all seem to be accepted by lld as well, so try to align
with what it seems GCC is doing and prefer the non-Linux emulations for
baremetal Arm/AArch64 targets.
(cherry picked from commit ee63c1f3520bca0acb859fcb4da49d3eb667c1ad)
Added:
Modified:
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Driver/ToolChains/Arch/AArch64.h
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/aarch64-toolchain.c
clang/test/Driver/arm-toolchain.c
clang/test/Driver/baremetal.cpp
Removed:
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 6bd710ec6b8b5..418f9fd9ca4c4 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -467,3 +467,18 @@ void aarch64::setPAuthABIInTriple(const Driver &D, const
ArgList &Args,
break;
}
}
+
+/// Is the triple {aarch64.aarch64_be}-none-elf?
+bool aarch64::isAArch64BareMetal(const llvm::Triple &Triple) {
+ if (Triple.getArch() != llvm::Triple::aarch64 &&
+ Triple.getArch() != llvm::Triple::aarch64_be)
+return false;
+
+ if (Triple.getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+ if (Triple.getOS() != llvm::Triple::UnknownOS)
+return false;
+
+ return Triple.getEnvironmentName() == "elf";
+}
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.h
b/clang/lib/Driver/ToolChains/Arch/AArch64.h
index 2057272867a17..2765ee8c3a6aa 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.h
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.h
@@ -30,6 +30,7 @@ std::string getAArch64TargetCPU(const llvm::opt::ArgList
&Args,
void setPAuthABIInTriple(const Driver &D, const llvm::opt::ArgList &Args,
llvm::Triple &triple);
+bool isAArch64BareMetal(const llvm::Triple &Triple);
} // end namespace aarch64
} // end namespace target
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 497f3330237b9..207150ea6f322 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -12,6 +12,7 @@
#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/InputInfo.h"
+#include "Arch/AArch64.h"
#include "Arch/ARM.h"
#include "Arch/RISCV.h"
#include "clang/Driver/Compilation.h"
@@ -31,21 +32,6 @@ using namespace clang::driver;
using namespace clang::driver::tools;
using namespace clang::driver::toolchains;
-/// Is the triple {aarch64.aarch64_be}-none-elf?
-static bool isAArch64BareMetal(const llvm::Triple &Triple) {
- if (Triple.getArch() != llvm::Triple::aarch64 &&
- Triple.getArch() != llvm::Triple::aarch64_be)
-return false;
-
- if (Triple.getVendor() != llvm::Triple::UnknownVendor)
-return false;
-
- if (Triple.getOS() != llvm::Triple::UnknownOS)
-return false;
-
- return Triple.getEnvironmentName() == "elf";
-}
-
static bool isRISCVBareMetal(const llvm::Triple &Triple) {
if (!Triple.isRISCV())
return false;
@@ -363,8 +349,9 @@ void BareMetal::findMultilibs(const Driver &D, const
llvm::Triple &Triple,
}
bool BareMetal::handlesTarget(const llvm::Triple &Triple) {
- return arm::isARMEABIBareMetal(Triple) || isAArch64BareMetal(Triple) ||
- isRISCVBareMetal(Triple) || isPPCBareMetal(Triple);
+ return arm::isARMEABIBareMetal(Triple) ||
+ aarch64::isAArch64BareMetal(Triple) || isRISCVBareMetal(Triple) ||
+ isPPCBareMetal(Triple);
}
Tool *BareMetal::buildLinker() const {
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 826e2ea7eb06d..3086c14fdaa4a 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -547,15 +547,22 @@ const char *tools::getLDMOption(const llvm::Triple &T,
const ArgList &Args) {
case llvm::Triple::aarch64:
if (T.isOSManagarm())
return "aarch64managarm";
+else if (aarch64::isAArch64BareMetal(T))
+ return "aarch64elf";
return "aarch64linux";
case llvm:
[llvm-branch-commits] [libc] 75c7e19 - Revert "[libc] Add -Wextra for libc tests (#133643)"
Author: William Huynh
Date: 2025-08-12T12:34:51+01:00
New Revision: 75c7e19456a30e054c93b9c6d7b4dec19830ee3a
URL:
https://github.com/llvm/llvm-project/commit/75c7e19456a30e054c93b9c6d7b4dec19830ee3a
DIFF:
https://github.com/llvm/llvm-project/commit/75c7e19456a30e054c93b9c6d7b4dec19830ee3a.diff
LOG: Revert "[libc] Add -Wextra for libc tests (#133643)"
This reverts commit e617dc80bf9376ca948ee7af8304ea00b2263b51.
Added:
Modified:
libc/cmake/modules/LLVMLibCTestRules.cmake
libc/test/UnitTest/FPExceptMatcher.cpp
libc/test/UnitTest/FPExceptMatcher.h
libc/test/UnitTest/HermeticTestUtils.cpp
libc/test/UnitTest/LibcDeathTestExecutors.cpp
libc/test/UnitTest/LibcTest.h
libc/test/include/stdbit_stub.h
libc/test/integration/src/pthread/pthread_mutex_test.cpp
libc/test/integration/src/spawn/posix_spawn_test.cpp
libc/test/integration/src/spawn/posix_spawn_test_binary.cpp
libc/test/integration/src/stdio/sprintf_size_test.cpp
libc/test/integration/src/stdlib/getenv_test.cpp
libc/test/integration/src/threads/cnd_test.cpp
libc/test/integration/src/threads/mtx_test.cpp
libc/test/integration/src/unistd/execv_test.cpp
libc/test/integration/src/unistd/execve_test.cpp
libc/test/integration/src/unistd/fork_test.cpp
libc/test/integration/src/unistd/getcwd_test.cpp
libc/test/integration/startup/linux/main_without_envp.cpp
libc/test/integration/startup/linux/tls_test.cpp
libc/test/src/__support/CPP/integer_sequence_test.cpp
libc/test/src/__support/freelist_heap_test.cpp
libc/test/src/math/exhaustive/hypotf16_test.cpp
libc/test/src/stdlib/StrfromTest.h
libc/test/src/string/memory_utils/op_tests.cpp
libc/test/src/strings/bzero_test.cpp
libc/utils/MPFRWrapper/MPFRUtils.h
Removed:
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake
b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 44cc6a35df886..30b1fd10a1774 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -40,7 +40,7 @@ function(_get_common_test_compile_options output_var c_test
flags)
endif()
# list(APPEND compile_options "-Wall")
-list(APPEND compile_options "-Wextra")
+# list(APPEND compile_options "-Wextra")
# -DLIBC_WNO_ERROR=ON if you can't build cleanly with -Werror.
if(NOT LIBC_WNO_ERROR)
# list(APPEND compile_options "-Werror")
diff --git a/libc/test/UnitTest/FPExceptMatcher.cpp
b/libc/test/UnitTest/FPExceptMatcher.cpp
index 9688d53496f94..d66066023984e 100644
--- a/libc/test/UnitTest/FPExceptMatcher.cpp
+++ b/libc/test/UnitTest/FPExceptMatcher.cpp
@@ -31,7 +31,7 @@ namespace testing {
static thread_local sigjmp_buf jumpBuffer;
static thread_local bool caughtExcept;
-static void sigfpeHandler([[maybe_unused]] int sig) {
+static void sigfpeHandler(int sig) {
caughtExcept = true;
siglongjmp(jumpBuffer, -1);
}
diff --git a/libc/test/UnitTest/FPExceptMatcher.h
b/libc/test/UnitTest/FPExceptMatcher.h
index 9b05e83bc1e3a..978501df7e3ed 100644
--- a/libc/test/UnitTest/FPExceptMatcher.h
+++ b/libc/test/UnitTest/FPExceptMatcher.h
@@ -43,7 +43,7 @@ class FPExceptMatcher : public Matcher {
// Takes ownership of func.
explicit FPExceptMatcher(FunctionCaller *func);
- bool match([[maybe_unused]] bool unused) { return exceptionRaised; }
+ bool match(bool unused) { return exceptionRaised; }
void explainError() override {
tlog << "A floating point exception should have been raised but it "
diff --git a/libc/test/UnitTest/HermeticTestUtils.cpp
b/libc/test/UnitTest/HermeticTestUtils.cpp
index 3c82d1e963643..f34a73f3e6805 100644
--- a/libc/test/UnitTest/HermeticTestUtils.cpp
+++ b/libc/test/UnitTest/HermeticTestUtils.cpp
@@ -29,9 +29,7 @@ int atexit(void (*func)(void));
// add_libc_hermetic_test properly. Such that they won't get correct linkage
// against the object containing this function. We create a dummy function that
// always returns 0 to indicate a failure.
-[[gnu::weak]] unsigned long getauxval([[maybe_unused]] unsigned long id) {
- return 0;
-}
+[[gnu::weak]] unsigned long getauxval(unsigned long id) { return 0; }
} // namespace LIBC_NAMESPACE_DECL
@@ -126,7 +124,7 @@ unsigned long __getauxval(unsigned long id) {
} // extern "C"
-void *operator new([[maybe_unused]] size_t size, void *ptr) { return ptr; }
+void *operator new(size_t size, void *ptr) { return ptr; }
void *operator new(size_t size) { return malloc(size); }
@@ -138,9 +136,7 @@ void operator delete(void *) {
__builtin_trap();
}
-void operator delete([[maybe_unused]] void *ptr, [[maybe_unused]] size_t size)
{
- __builtin_trap();
-}
+void operator delete(void *ptr, size_t size) { __builtin_trap(); }
// Defining members in the std namespace is not preferred. But, we do it here
// so that we can use it to define the operator new which takes
std::
[llvm-branch-commits] [llvm] b9e3a81 - Revert "[ADT] Simplify getFirstEl (NFC) (#153127)"
Author: Benjamin Chetioui
Date: 2025-08-12T16:38:16+02:00
New Revision: b9e3a814ee9387ab02640d7b34261830782ea598
URL:
https://github.com/llvm/llvm-project/commit/b9e3a814ee9387ab02640d7b34261830782ea598
DIFF:
https://github.com/llvm/llvm-project/commit/b9e3a814ee9387ab02640d7b34261830782ea598.diff
LOG: Revert "[ADT] Simplify getFirstEl (NFC) (#153127)"
This reverts commit 478aa0270915d9866bd3fe6fa2a4d156c6b473a8.
Added:
Modified:
llvm/include/llvm/ADT/SmallVector.h
Removed:
diff --git a/llvm/include/llvm/ADT/SmallVector.h
b/llvm/include/llvm/ADT/SmallVector.h
index 6da519adcee6f..80f7734b86907 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -128,8 +128,8 @@ class SmallVectorTemplateCommon
/// SmallVectorStorage is properly-aligned even for small-size of 0.
void *getFirstEl() const {
return const_cast(reinterpret_cast(
-reinterpret_cast *>(this)
-->FirstEl));
+reinterpret_cast(this) +
+offsetof(SmallVectorAlignmentAndSize, FirstEl)));
}
// Space after 'FirstEl' is clobbered, do not add any instance vars after it.
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] e852d2d - Revert "[DirectX][objdump] Add support for printing signatures (#152531)"
Author: Chris B
Date: 2025-08-12T17:33:42-05:00
New Revision: e852d2d157ff0c5cb8dd1ec68a7861b3b093c166
URL:
https://github.com/llvm/llvm-project/commit/e852d2d157ff0c5cb8dd1ec68a7861b3b093c166
DIFF:
https://github.com/llvm/llvm-project/commit/e852d2d157ff0c5cb8dd1ec68a7861b3b093c166.diff
LOG: Revert "[DirectX][objdump] Add support for printing signatures (#152531)"
This reverts commit 9526d3b0b92e9ce1a537227abdab4801488343a6.
Added:
Modified:
llvm/include/llvm/Object/DXContainer.h
llvm/tools/llvm-objdump/DXContainerDump.cpp
Removed:
llvm/test/tools/llvm-objdump/DXContainer/input-output-signatures.yaml
diff --git a/llvm/include/llvm/Object/DXContainer.h
b/llvm/include/llvm/Object/DXContainer.h
index 93d39dabae4b9..ad1b2361ff064 100644
--- a/llvm/include/llvm/Object/DXContainer.h
+++ b/llvm/include/llvm/Object/DXContainer.h
@@ -603,8 +603,6 @@ class LLVM_ABI DXContainerObjectFile : public ObjectFile {
}
public:
- const DXContainer &getDXContainer() const { return Container; }
-
static bool classof(const Binary *v) { return v->isDXContainer(); }
Expected getSymbolName(DataRefImpl) const override;
diff --git
a/llvm/test/tools/llvm-objdump/DXContainer/input-output-signatures.yaml
b/llvm/test/tools/llvm-objdump/DXContainer/input-output-signatures.yaml
deleted file mode 100644
index 7cc11af251182..0
--- a/llvm/test/tools/llvm-objdump/DXContainer/input-output-signatures.yaml
+++ /dev/null
@@ -1,167 +0,0 @@
-# RUN: yaml2obj %s -o %t
-# RUN: llvm-objdump -p %t | FileCheck %s --match-full-lines --strict-whitespace
-
-# This test covers llvm-objdump printing private headers for the ISG1, OSG1,
and
-# PSG1 "parts" of the DX container file format. The test uses a few absurdly
-# large values and long string names to ensure that the columns in the printed
-# table widen correctly.
-
!dxcontainer
-Header:
- Hash:[ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
- Version:
-Major: 1
-Minor: 0
- FileSize:630
- PartCount: 3
- PartOffsets: [ 64, 124, 184 ]
-Parts:
- - Name:ISG1
-Size:52
-Signature:
- Parameters:
-- Stream: 0
- Name:AAA_HSFoo
- Index: 4391238# This value forces the index column to
widen
- SystemValue: Undefined
- CompType:Float32
- Register:0
- Mask:7
- ExclusiveMask: 2
- MinPrecision:Default
- - Name:OSG1
-Size:52
-Signature:
- Parameters:
-- Stream: 0
- Name:SV_Position
- Index: 0
- SystemValue: Position
- CompType:Float32
- Register:2147483647 # This value forces the register column
to widen
- Mask:15
- ExclusiveMask: 0
- MinPrecision:Default
- - Name:PSG1
-Size:402
-Signature:
- Parameters:
-- Stream: 0
- Name:SV_TessFactor
- Index: 0
- SystemValue: FinalQuadEdgeTessfactor # The tessfactor forces
the SysVal column to widen
- CompType:Float32
- Register:0
- Mask:8
- ExclusiveMask: 8
- MinPrecision:Default
-- Stream: 0
- Name:BBB
- Index: 0
- SystemValue: Undefined
- CompType:Float32
- Register:0
- Mask:7
- ExclusiveMask: 0
- MinPrecision:Default
-- Stream: 0
- Name:SV_TessFactor
- Index: 1
- SystemValue: FinalQuadEdgeTessfactor
- CompType:Float32
- Register:1
- Mask:8
- ExclusiveMask: 8
- MinPrecision:Default
-- Stream: 0
- Name:BBB
- Index: 1
- SystemValue: Undefined
- CompType:Float32
- Register:1
- Mask:7
- ExclusiveMask: 0
- MinPrecision:Default
-- Stream: 0
- Name:SV_TessFactor
- Index: 2
- SystemValue: FinalQuadEdgeTessfactor
- CompType:Float32
- Register:2
- Mask:8
- ExclusiveMask: 8
- MinPrecision:Default
-- Stream: 0
- Name:BBB
- Index: 2
- SystemValue: Undefined
- CompType:Float32
- Register:
[llvm-branch-commits] [lldb] c6dae16 - Revert "[lldb] Use the Python limited API with SWIG 4.2 or later (#153119)"
Author: Jonas Devlieghere
Date: 2025-08-12T20:07:51-05:00
New Revision: c6dae16cd478083ce7483337d27c37daa602ecbe
URL:
https://github.com/llvm/llvm-project/commit/c6dae16cd478083ce7483337d27c37daa602ecbe
DIFF:
https://github.com/llvm/llvm-project/commit/c6dae16cd478083ce7483337d27c37daa602ecbe.diff
LOG: Revert "[lldb] Use the Python limited API with SWIG 4.2 or later (#153119)"
This reverts commit c14ca4520f9107ac3f903436e18f42c2667b648a.
Added:
Modified:
lldb/cmake/modules/LLDBConfig.cmake
Removed:
diff --git a/lldb/cmake/modules/LLDBConfig.cmake
b/lldb/cmake/modules/LLDBConfig.cmake
index ca574a142b9dd..a9679d63e010d 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -68,6 +68,7 @@ add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable
libfbsdvmcore support in
option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available"
ON)
option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
option(LLDB_ENABLE_PROTOCOL_SERVERS "Enable protocol servers (e.g. MCP) in
LLDB" ON)
+option(LLDB_ENABLE_PYTHON_LIMITED_API "Force LLDB to only use the Python
Limited API (requires SWIG 4.2 or later)" OFF)
option(LLDB_NO_INSTALL_DEFAULT_RPATH "Disable default RPATH settings in
binaries" OFF)
option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver for testing
(Darwin only)." OFF)
option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries when installing
lldb." OFF)
@@ -172,14 +173,6 @@ if (LLDB_ENABLE_PYTHON)
"Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME environment
variable will be used to to locate Python."
${default_embed_python_home})
- if (SWIG_VERSION VERSION_GREATER_EQUAL "4.2")
-set(default_enable_python_limited_api ON)
- else()
-set(default_enable_python_limited_api OFF)
- endif()
- option(LLDB_ENABLE_PYTHON_LIMITED_API "Force LLDB to only use the Python
Limited API (requires SWIG 4.2 or later)"
-${default_enable_python_limited_api})
-
include_directories(${Python3_INCLUDE_DIRS})
if (LLDB_EMBED_PYTHON_HOME)
get_filename_component(PYTHON_HOME "${Python3_EXECUTABLE}" DIRECTORY)
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] d7b5ea3 - Revert "[msan] Improve packed multiply-add instrumentation (#152941)"
Author: Thurston Dang
Date: 2025-08-12T21:31:33-07:00
New Revision: d7b5ea35082fdf50f3f07d7fc59f0e50f9af6dba
URL:
https://github.com/llvm/llvm-project/commit/d7b5ea35082fdf50f3f07d7fc59f0e50f9af6dba
DIFF:
https://github.com/llvm/llvm-project/commit/d7b5ea35082fdf50f3f07d7fc59f0e50f9af6dba.diff
LOG: Revert "[msan] Improve packed multiply-add instrumentation (#152941)"
This reverts commit ba603b5e4d44f1a25207a2a00196471d2ba93424.
Added:
Modified:
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/test/Instrumentation/MemorySanitizer/X86/avx2-intrinsics-x86.ll
llvm/test/Instrumentation/MemorySanitizer/X86/mmx-intrinsics.ll
llvm/test/Instrumentation/MemorySanitizer/X86/sse2-intrinsics-x86.ll
llvm/test/Instrumentation/MemorySanitizer/i386/avx2-intrinsics-i386.ll
llvm/test/Instrumentation/MemorySanitizer/i386/mmx-intrinsics.ll
llvm/test/Instrumentation/MemorySanitizer/i386/sse2-intrinsics-i386.ll
llvm/test/Instrumentation/MemorySanitizer/vector_arith.ll
Removed:
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 4cef57d43f203..21bd4164385ab 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -3641,10 +3641,9 @@ struct MemorySanitizerVisitor : public
InstVisitor {
setOriginForNaryOp(I);
}
- // Get an MMX-sized (64-bit) vector type, or optionally, other sized
- // vectors.
- Type *getMMXVectorTy(unsigned EltSizeInBits,
- unsigned X86_MMXSizeInBits = 64) {
+ // Get an MMX-sized vector type.
+ Type *getMMXVectorTy(unsigned EltSizeInBits) {
+const unsigned X86_MMXSizeInBits = 64;
assert(EltSizeInBits != 0 && (X86_MMXSizeInBits % EltSizeInBits) == 0 &&
"Illegal MMX vector element size");
return FixedVectorType::get(IntegerType::get(*MS.C, EltSizeInBits),
@@ -3844,78 +3843,20 @@ struct MemorySanitizerVisitor : public
InstVisitor {
setOriginForNaryOp(I);
}
- // Instrument multiply-add intrinsics.
- //
- // e.g., Two operands:
- // <4 x i32> @llvm.x86.sse2.pmadd.wd(<8 x i16> %a, <8 x i16> %b)
- // <1 x i64> @llvm.x86.mmx.pmadd.wd(<1 x i64> %a, <1 x i64> %b)
- //
- // Three operands are not implemented yet:
- // <4 x i32> @llvm.x86.avx512.vpdpbusd.128
- // (<4 x i32> %s, <4 x i32> %a, <4 x i32> %b)
- // (the result of multiply-add'ing %a and %b is accumulated with %s)
- void handleVectorPmaddIntrinsic(IntrinsicInst &I, unsigned ReductionFactor,
- unsigned EltSizeInBits = 0) {
+ // Instrument multiply-add intrinsic.
+ void handleVectorPmaddIntrinsic(IntrinsicInst &I,
+ unsigned MMXEltSizeInBits = 0) {
+Type *ResTy =
+MMXEltSizeInBits ? getMMXVectorTy(MMXEltSizeInBits * 2) : I.getType();
IRBuilder<> IRB(&I);
-
-[[maybe_unused]] FixedVectorType *ReturnType =
-cast(I.getType());
-assert(isa(ReturnType));
-
-assert(I.arg_size() == 2);
-
-// Vectors A and B, and shadows
-Value *Va = I.getOperand(0);
-Value *Vb = I.getOperand(1);
-
-Value *Sa = getShadow(&I, 0);
-Value *Sb = getShadow(&I, 1);
-
-FixedVectorType *ParamType =
-cast(I.getArgOperand(0)->getType());
-assert(ParamType == I.getArgOperand(1)->getType());
-
-assert(ParamType->getPrimitiveSizeInBits() ==
- ReturnType->getPrimitiveSizeInBits());
-
-// Step 1: instrument multiplication of corresponding vector elements
-if (EltSizeInBits) {
- ParamType = cast(
- getMMXVectorTy(EltSizeInBits, ParamType->getPrimitiveSizeInBits()));
-
- Va = IRB.CreateBitCast(Va, ParamType);
- Vb = IRB.CreateBitCast(Vb, ParamType);
-
- Sa = IRB.CreateBitCast(Sa, getShadowTy(ParamType));
- Sb = IRB.CreateBitCast(Sb, getShadowTy(ParamType));
-} else {
- assert(ParamType->getNumElements() ==
- ReturnType->getNumElements() * ReductionFactor);
-}
-
-Value *Sab = IRB.CreateOr(Sa, Sb);
-
-// Multiplying an uninitialized / element by zero results in an initialized
-// element.
-Value *Zero = Constant::getNullValue(Va->getType());
-Value *VaNotZero = IRB.CreateICmpNE(Va, Zero);
-Value *VbNotZero = IRB.CreateICmpNE(Vb, Zero);
-Value *VaAndVbNotZero = IRB.CreateAnd(VaNotZero, VbNotZero);
-
-// After multiplying e.g., <8 x i16> %a, <8 x i16> %b, we should have
-// <8 x i32> %ab, but we cheated and ended up with <8 x i16>.
-Sab = IRB.CreateAnd(Sab, IRB.CreateSExt(VaAndVbNotZero, Sab->getType()));
-
-// Step 2: instrument horizontal add
-// e.g., collapse <8 x i16> into <4 x i16> (reduction factor == 2)
-//<16 x i8> into <4 x i8> (reduction factor == 4)
-Value *OutShad
