llvm-project/llvm/test/Transforms/MergeFunc/merge-fp-intrinsics.ll
Oskar Wirga e06fc2b2e0
Fix: Distinguish CFI Metadata Checks in MergeFunctions Pass (#65963)
This diff fixes an issue in the MergeFunctions pass where two different
Control Flow Integrity (CFI) metadata checks were incorrectly considered
identical. These merges would lead to runtime violations down the line
as two separate objects contained a single destructor which itself
contained checks for only one of the objects.

Here I update the comparison logic to take into account the metadata at
llvm.type.test checks. Now, only truly identical checks will be
considered for merging, thus preserving the integrity of each check.

Previous discussion: https://reviews.llvm.org/D154119
2023-09-23 12:28:29 +02:00

29 lines
1.6 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
;; Make sure internal constrained FP intrinsics still merge properly
; RUN: opt -passes=mergefunc -S < %s | FileCheck %s
declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, metadata)
define float @func1(float %a, float %b) {
; CHECK-LABEL: define float @func1
; CHECK-SAME: (float [[A:%.*]], float [[B:%.*]]) {
; CHECK-NEXT: [[RESULT:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A]], float [[B]], metadata !"round.dynamic", metadata !"fpexcept.strict")
; CHECK-NEXT: [[RESULT_2:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A]], float [[B]], metadata !"round.dynamic", metadata !"fpexcept.strict")
; CHECK-NEXT: ret float [[RESULT]]
;
%result = call float @llvm.experimental.constrained.fadd.f32(float %a, float %b, metadata !"round.dynamic", metadata !"fpexcept.strict")
%result_2 = call float @llvm.experimental.constrained.fadd.f32(float %a, float %b, metadata !"round.dynamic", metadata !"fpexcept.strict")
ret float %result
}
define float @func2(float %a, float %b) {
; CHECK-LABEL: define float @func2
; CHECK-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) {
; CHECK-NEXT: [[TMP3:%.*]] = tail call float @func1(float [[TMP0]], float [[TMP1]])
; CHECK-NEXT: ret float [[TMP3]]
;
%result = call float @llvm.experimental.constrained.fadd.f32(float %a, float %b, metadata !"round.dynamic", metadata !"fpexcept.strict")
%result_2 = call float @llvm.experimental.constrained.fadd.f32(float %a, float %b, metadata !"round.dynamic", metadata !"fpexcept.strict")
ret float %result
}