From patchwork Fri Nov 24 16:26:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cupertino Miranda X-Patchwork-Id: 1868241 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2023-11-20 header.b=bK8rj3Yb; dkim=pass (1024-bit key; unprotected) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-oracle-onmicrosoft-com header.b=O6H1GBw5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4ScL3X4bLfz1ySj for ; Sat, 25 Nov 2023 03:27:03 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FA4A38582B8 for ; Fri, 24 Nov 2023 16:27:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 7F703385840E for ; Fri, 24 Nov 2023 16:26:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F703385840E Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=oracle.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7F703385840E Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700843206; cv=pass; b=v5/T7AQ5LY+iXxGlXCWTuDdhGFNyFlUCyGXtPPY0BEi9KSVcDIcl2KcQb87kt6J9tKImez6H+zbzNggu3a006uY1jt4Fdqz3GtMfI2URkuf6XuRJr15ghKMPSGVpylI4TDbNUywB43jfrHNqFRu6WL9XZW2uRb+xNWMMom6n2uI= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700843206; c=relaxed/simple; bh=ny3ngxu0pGZbYSWk/1KrTjxDbm0G9MAy/u/JcOyzhU0=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=RHiG+pOPYSzObKbKDnjEQ04QkIf9l2ccBPUMckfyeZ8GU/98Nao7juoyipwIcFkfKDErEBTBPucvjDF7ZP91SLf9RTw1UJdz45f0XGzC4nDTlAL2AIz9Q2HIeyS2JApSJ4wbroRpP/5flELkJmxEFcIMdNwcQPOSHfy4EPIJTrw= ARC-Authentication-Results: i=2; server2.sourceware.org Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6Z0r-0004Qc-UM for gcc-patches@gnu.org; Fri, 24 Nov 2023 11:26:44 -0500 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AOGJ27J019217 for ; Fri, 24 Nov 2023 16:26:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-type : mime-version; s=corp-2023-11-20; bh=W3t8gWiFSksMNTLVBM1PYuOUY4ugcFr4hTtKsyi0FZA=; b=bK8rj3Ybi8rQQYeOrtFpJo0wxAymA1Hby4FWCle/H812Tx9gOdJ+0Ywft5/3dlU7RHij lpTlhUQ1NrMzlR+G7ttOV+MLCH/jvgKkBxwTGM0oW8t3hCJmsqyWsKVJhcjjv6v6JlLX CaKW4tuey/Chik44EF0TYDPsNVJUlmWeC1NcfclbPCwwHO2iqncMFSPEOjDEuNfmbgny uRrbxv4wixKCtIK/fFLtlDIKVdZOkubE5eT8Z4TLKVKjTBCdsgOZ0IyAi0BPlzhcGNjy PaAKWd/TK/UVLz9wHW1y/SqwaNWE6E33DQSmGWUWeKcNuXZzLpA11QsA47Jr2rSO4MLn cw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3uen5bkfk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 24 Nov 2023 16:26:38 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3AOE1wnZ011129 for ; Fri, 24 Nov 2023 16:26:37 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3uekqbrguw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 24 Nov 2023 16:26:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b/zCZdhl0RwVflcoz+tZPlhGv7J3XPwMJUtqnDMt7DCpVJK0gp8JuyttjkZ8suEtHFvOdC/sghQx/WSPJ7Dpv/8F6uh3VB9x7mnivwUSEacLqWBiPzjjZha1pDLLMjk0PIF9rNxAy6eD6l/64KOBWdz9F+CUEJXinfrQLMKHNdK6EdE4o12j17MESebocks1Ds+CRYb6/9p4hSHGXlXTSrtLWv8nNuOpPSBMXNqiyJ9wJftiFlcEkfMfs8zM4yehTzO0pcKs/RLBLppgK1VmTZsym/26gUydb2yx4fvdXsoKC3UGpheMxmafGIOl51sftQFQ3RrJSXNBvrRF6pnxSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W3t8gWiFSksMNTLVBM1PYuOUY4ugcFr4hTtKsyi0FZA=; b=BRBk/Pz3jQMMmXzC8TW19tcB5+/RoDyPdOC/wBoC5uPmfcianTGtjVBwp5eMHSItEVRlojQX177HFMhkBjmcWC3g79rdh7KP/mXpU16r2E8hdgla66AYZqOA2wuuqv3fbLp/K3twO5h14XfyGUD1eEQvI6d3HxoJrDVmoZAiAJ4y/0oeo3yHYzP34dIn/BMQXlPfUjixJj0cX71dgb/DRqDap6cRBA5shlWVlmlo2O/vH4cbUp3DU9Q4cUTcIG83WnBWdLgqlKYaUIEfOVjW7WkKEreCiM2hMCl0n5QxzmZgdAbEBWuahJ4OelaGJSPGlsVIa10Pi1soeSFcjhmaGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W3t8gWiFSksMNTLVBM1PYuOUY4ugcFr4hTtKsyi0FZA=; b=O6H1GBw50zwUtXT8zAyOlB/hqiAZV/3QZ+ykQ9C7CnYj/tczgvkBLREG4jMCtFWIfL82T6AZukLx7E1im1Bd3w3Uifg0I4V26iDMkAZjPiyZD6f4xKDH0Qk+BpP4WVwUkyfXFp9Bi5+QcXX7iDjsTvmSJhkGOHShw7Iv/znTGPs= Received: from BN6PR1001MB2340.namprd10.prod.outlook.com (2603:10b6:405:30::36) by SJ0PR10MB5408.namprd10.prod.outlook.com (2603:10b6:a03:3ba::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.20; Fri, 24 Nov 2023 16:26:35 +0000 Received: from BN6PR1001MB2340.namprd10.prod.outlook.com ([fe80::fec4:3a58:6118:aab2]) by BN6PR1001MB2340.namprd10.prod.outlook.com ([fe80::fec4:3a58:6118:aab2%6]) with mapi id 15.20.7025.020; Fri, 24 Nov 2023 16:26:34 +0000 User-agent: mu4e 1.4.15; emacs 28.1 From: Cupertino Miranda To: gcc-patches@gnu.org Cc: "Jose E. Marchesi" , david.faust@oracle.com Subject: bpf: Throw error when external libcalls are generated. Date: Fri, 24 Nov 2023 16:26:30 +0000 Message-ID: <877cm7jex5.fsf@oracle.com> X-ClientProxiedBy: AS4P251CA0019.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d3::7) To BN6PR1001MB2340.namprd10.prod.outlook.com (2603:10b6:405:30::36) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN6PR1001MB2340:EE_|SJ0PR10MB5408:EE_ X-MS-Office365-Filtering-Correlation-Id: 79beff45-4a5a-4a4e-b458-08dbed0a1fad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YceQ7vOOv4HQ5xgZZGdbkJpHWtioCUIe18af/6LQvIUjLmhfjT+k5Jrx1c8J4YsjxWFGtHvHclFfTum+SKY0RDcd6QzczelYuNDnA+lr0LDmGKmopMRAVHu2hBXVurx7A83UMLbxc5lHnoIGxaKFJVLmFOjv73krmE4Lmzqojz+a2jcnpK74fEZMooBqZWTRHBZI2shiftOCUpuQw3jT1X2obh6eJDNmOHuTnpsIrbVm1XBzc/co2E+2ff8/Y3UnUvUq460kmB7j+hwP72YaVkcLFPtBecTcoIvyqP/0LXVOljcQQ6jmTr9k++d8TMPs2vCMmdTQ4Hj1Ix5Jq2t0tw4wFb0eFc9N3VKHeF5+lzPK5PDHOrlkLSnGZe6XxFhrPJEfbpmLbGpngW+xMzMrZxPsC/yWAn2CG9m3Tn/3fKkwI1Ef5HTscTtpwr9fjePbTqq8LTaUeeUuYKU//SRYbDXQ5N0vQbuC/ebK5FHXvln0YstLd0lXeqz8MOgp+rIA6iJYY4J7rkcpuTemg97wfohzJszwwBI/QL6amX2H9yHpUjVYzuhqlz2KXHvJfPqf/PlLIMStdROC4dejtZbkK572lPgDtfThmIQbj3aKVu3Fo5Qdc44BkCEoFLxr2OjI X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR1001MB2340.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(136003)(396003)(366004)(346002)(376002)(230173577357003)(230273577357003)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(8936002)(6666004)(2906002)(86362001)(8676002)(66946007)(6512007)(107886003)(38100700002)(316002)(66556008)(66476007)(6916009)(6506007)(2616005)(6486002)(478600001)(36756003)(83380400001)(5660300002)(4326008)(41300700001)(44832011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pZeYby0KHnzMoCRmZkgzPTyWBUXtWToCwfpFtoQ1EQQqaSSOt/ssMi01tQMR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3YeMKV7FK5Khd2zviMbfo4mAVanszMq9pkZKfHuCSEoVpz5fgSyXpm8V0BBqXYbxRj/ruVxc/YjGH8UGg1t9weUnsXRRbi/k/Ajzi6hUCABddDY0VAf0Whc3wOdsVHjIcQYaQk9Nzttx8F5HsVfXmUxKGjrp2VWe2xwEGa8Omk/KiA04xQu/kNNzm9vI6bWiv4QJwUbzdmoV5GEQhnU6vWBUCirABUH4AOJolN0h1M5Yi/U4CFAZYK1bEF9+vuhHLagPL+kANuONHm/rXS20quu6W X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 79beff45-4a5a-4a4e-b458-08dbed0a1fad X-MS-Exchange-CrossTenant-AuthSource: BN6PR1001MB2340.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2023 16:26:34.1898 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b3kSlp9slLL1VWJQkg3WSfCuT7JyXWT78dckGAFs04V7FNstN0pLFSWFu2EaG9kWTpSNEYSWB2o6fOUZpOPRq1jPRW6sQEX4rT59Meaez9U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5408 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-24_03,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311240128 X-Proofpoint-GUID: LkIXtt1L8xsJwTvdNblxJfFCc-aMxOd4 X-Proofpoint-ORIG-GUID: LkIXtt1L8xsJwTvdNblxJfFCc-aMxOd4 Received-SPF: pass client-ip=205.220.165.32; envelope-from=cupertino.miranda@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi everyone, The attached patch is a temporary solution for the lack of proper linker and external library linking of the eBPF platform. Any calls created by the compiler, that would usually be defined within libgcc, will endup being undefined in bpftool, when GCC the compiled code is passed. This patch anticipates that error to the compiler, by verifiying if any of those calls are being generated, and reporting as an error. Looking forward to your comments. Cheers, Cupertino commit c2110ae497c7ff83c309f172bc265973652b760d Author: Cupertino Miranda Date: Thu Nov 23 22:28:01 2023 +0000 This patch enables errors when external calls are created. When architectural limitations or usage of builtins implies the compiler to create function calls to external libraries that implement the functionality, GCC will now report an error claiming that this function calls are not compatible with eBPF target. Examples of those are the usage of __builtin_memmove and a sign division in BPF ISA v3 or below that will require to call __divdi3. This is currently an eBPF limitation which does not support linking of object files but rather "raw" non linked ones. Those object files are loaded and relocated by libbpf and the kernel. gcc/ChangeLog: * config/bpf/bpf.cc (bpf_output_call): Report error in case the function call is for a builtin. (bpf_external_libcall): Added target hook to detect and report error when other external calls that are not builtins. diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc index 0c9d5257c384..1c84113055b1 100644 --- a/gcc/config/bpf/bpf.cc +++ b/gcc/config/bpf/bpf.cc @@ -744,6 +744,15 @@ bpf_output_call (rtx target) xops[0] = GEN_INT (TREE_INT_CST_LOW (TREE_VALUE (attr_args))); output_asm_insn ("call\t%0", xops); } + else if (fndecl_built_in_p (decl)) + { + /* For now lets report this as an error while we are not able to + link eBPF object files. In particular with libgcc. */ + tree name = DECL_NAME (decl); + error ("call to external builtin %s in function, which is not supported by " + "eBPF", name != NULL_TREE ? IDENTIFIER_POINTER (name) : "(anon)"); + output_asm_insn ("call 0", NULL); + } else output_asm_insn ("call\t%0", &target); @@ -763,6 +772,18 @@ bpf_output_call (rtx target) return ""; } +static void +bpf_external_libcall (rtx fun) +{ + tree decl = SYMBOL_REF_DECL (fun); + tree name = DECL_NAME (decl); + error ("call to external libcall %s in function, which is not supported by " + "eBPF", name != NULL_TREE ? IDENTIFIER_POINTER (name) : "(anon)"); +} + +#undef TARGET_ASM_EXTERNAL_LIBCALL +#define TARGET_ASM_EXTERNAL_LIBCALL bpf_external_libcall + /* Print register name according to assembly dialect. In normal syntax registers are printed like %rN where N is the register number. diff --git a/gcc/testsuite/gcc.target/bpf/atomic-cmpxchg-2.c b/gcc/testsuite/gcc.target/bpf/atomic-cmpxchg-2.c index 4036570ac601..fec720584e48 100644 --- a/gcc/testsuite/gcc.target/bpf/atomic-cmpxchg-2.c +++ b/gcc/testsuite/gcc.target/bpf/atomic-cmpxchg-2.c @@ -6,7 +6,7 @@ foo (int *p, int *expected, int desired) { return __atomic_compare_exchange (p, expected, &desired, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED); -} +} /* { dg-error "call to external builtin" } */ int foo64 (long *p, long *expected, long desired) diff --git a/gcc/testsuite/gcc.target/bpf/atomic-fetch-op-3.c b/gcc/testsuite/gcc.target/bpf/atomic-fetch-op-3.c index 044a2f76474b..ea1b8e48928a 100644 --- a/gcc/testsuite/gcc.target/bpf/atomic-fetch-op-3.c +++ b/gcc/testsuite/gcc.target/bpf/atomic-fetch-op-3.c @@ -9,7 +9,7 @@ long test_atomic_fetch_add (long x) { return __atomic_fetch_add (&val, x, __ATOMIC_ACQUIRE); -} +} /* { dg-error "call to external builtin" } */ long test_atomic_fetch_sub (long x) diff --git a/gcc/testsuite/gcc.target/bpf/atomic-op-3.c b/gcc/testsuite/gcc.target/bpf/atomic-op-3.c index b2ce28926347..fefafd6b748f 100644 --- a/gcc/testsuite/gcc.target/bpf/atomic-op-3.c +++ b/gcc/testsuite/gcc.target/bpf/atomic-op-3.c @@ -20,7 +20,7 @@ void test_atomic_and (int x) { __atomic_and_fetch (&val, x, __ATOMIC_ACQUIRE); -} +} /* { dg-error "call to external builtin" } */ void test_atomic_nand (int x) diff --git a/gcc/testsuite/gcc.target/bpf/atomic-xchg-2.c b/gcc/testsuite/gcc.target/bpf/atomic-xchg-2.c index 3b6324e966b8..eab695bf388c 100644 --- a/gcc/testsuite/gcc.target/bpf/atomic-xchg-2.c +++ b/gcc/testsuite/gcc.target/bpf/atomic-xchg-2.c @@ -7,7 +7,7 @@ int foo (int *p, int *new) int old; __atomic_exchange (p, new, &old, __ATOMIC_RELAXED); return old; -} +} /* { dg-error "call to external builtin" } */ int foo64 (long *p, long *new) { diff --git a/gcc/testsuite/gcc.target/bpf/diag-sdiv.c b/gcc/testsuite/gcc.target/bpf/diag-sdiv.c index c48bbf03df97..c3332558e7d2 100644 --- a/gcc/testsuite/gcc.target/bpf/diag-sdiv.c +++ b/gcc/testsuite/gcc.target/bpf/diag-sdiv.c @@ -7,6 +7,6 @@ foo () { signed int x = 5; signed int y = 2; - signed int z = x / y; + signed int z = x / y; /* { dg-error "call to external libcall" } */ } /* { dg-final { scan-assembler-not "sdiv(32)?\t%r" } } */ diff --git a/gcc/testsuite/gcc.target/bpf/diag-smod.c b/gcc/testsuite/gcc.target/bpf/diag-smod.c index d3df308217f3..25bcb1e4ffdb 100644 --- a/gcc/testsuite/gcc.target/bpf/diag-smod.c +++ b/gcc/testsuite/gcc.target/bpf/diag-smod.c @@ -7,6 +7,6 @@ foo () { signed int x = 5; signed int y = 2; - signed int z = x % y; + signed int z = x % y; /* { dg-error "call to external libcall" } */ } /* { dg-final { scan-assembler-not "smod(32)?\t%r" } } */